Hi All,
I am trying to add a new row to the grid using javascript using the following:
var cust = { "iRowIndex": rowCount, "CustLName":"Cruise","nvchType":"The type"};
grid.get_rows().add(cust);
I get an error saying Invalid Cast Exception: Unable to convert from Dictionary.
I am using v10.3.20103.1013
Any help would be appreciated.
Thanks in advance
PS- I have already tried searching the forums for solutions.
Hi omkar12345,
Thank you for posting in the community.
Note that the add() function expects an array argument containing the cell values for the new row (as opposed to an object). For instance:
ig_controls.WebDataGrid1.get_rows().add(new Array('value1','value2'))
Please let me know if this helps.
Thanks for the reply.
Some posts mentioned that an object be bassed and some mention the approach that you mentioned.
I am facing a problem with that approach too. Let me elaborate.
My grid has 4 columns.
1. Boolean - Checkbox
2. Integer - BoundColumn
3. & 4. String - BoundColumn
Now I need to add a row to the grid via javascript such that it has the checkbox checked.
I tried using add(new Array(true,1,"some Description","some text");
This adds a row(only alternate times the add is called) but the data is not what is expected. It would be great if you could help me understand how the order of the values passed(true,1,"","" OR 1,"",true,"") affects the add operation.
Thanks
Thank you for your reply.
The array values passed to the add() function are inserted in the new row according to the order in which columns appear in the grids column collection. Note that this may differ from the visible indeces of columns. I.e if your columns are defined and inserted in the grid with the order:
3. & 4. String - BoundColumn,
then the values in the adding array should be in the above order irrespective of whether the columns have been switched/moved.
Please feel free to contact me if you have any questions regarding this scenario.