Hi There -
Working with the new WebDataGrid and I've damn near got it working the way I want. I initially populate the grid with a stored procedure from a SQL table, and I've got AutoCrud turned off and Batch Update turned on. I can add a new row using JavaScript, but the error I'm seeing in the debugger is because I'm not generating a new, unique primary key for my ID column which I've set as the DataKeyValue - its an integer field, and I'm guessing there's a way I can programatically roll through the grid and determine the max value, and add one to it, and use that as my key value when I call the grid.get_rows().add(row) method, just not sure how to go about it.
Thanks,
Jeff
p.s. this version of the grid control (11.2) is way uber-cool compared to the 6.2 version I have been working with.
Hi Jeff,
Glad to hear that you like the WebDataGrid. If you add a row and do not give a DataKeyFields value in the new row, we should autogenerate a temporary one on the client. Are you passing in null for that column or were you taking a guess?
regards,David Young
Hi David,
In my function, I was trying to pass in a values using the .add() function. I've actually come up with something that seems to work - I'll post it in case it is valuable to other memebers looking to do something similar.
var
grid = $find("grid");
var rows = grid.get_rows();
var max_ID = 0;
for (var i = 0; i < rows.get_length(); i++) {
var row = rows.get_row(i);
if (row.get_cell(0).get_value() >= max_ID) {
max_ID = row.get_cell(0).get_value() + 1
}
This loop insures I generate a unique ID for my grid - and I'm now about to add multiple rows clientside in batch update mode. Since my grids are only likely to contain 100 or less rows, I'm ok with the performance hit here and I can set default values for the other columns of my grid.