I have a Webdatagrid, I want to auto populate data for some cells when add new row.
eg.
var grid=$find(grid_Name);
//I add new row here
var newRow = grid.get_rows().get_row(grid.get_rows().get_length()-1); // I get a new row
newRow.get_cellByColumnKey("myCell").set_value(myValue); // myValue != null or empty
newRow.get_cellByColumnKey("myCell").set_text(myText); // myText != empty
When I used: newRow.get_cellByColumnKey("myCell").get_value();
I received empty value(or zero if column is number). But if I don't set_text, it work.
How can I get value from new row?
Thanks & Regards!
Hello,
Thank you for your post!
About your question, the approach that you follow is correct, but it depends on which event you try to get values. I have made you a sample that shows how to get old/new values (including number columns) after row is added to the WebDataGrid. If this is not helpful to you, please provide me with sample that is reproducing the issue.
Code snippet:
If you have any further questions do not hesitate to contact me.
Hello Zdravko Kolev,
Thanks for your reply.
When I press tab key (left focus status), I want to add a new row and auto populate data for some cells. This data get from cells of one row above.
function UWG_Editing_CellValueChanged(sender,e){
// I get & set value here
// My issue occurs when I set text (if not, It work fine)
}
I'm just following up to see if you need any further assistance with this issue. If so do not hesitate to contact me.
Hello
I'm just checking if you have resolved your issue.
Thank you for the sample!
After further investigation I have found the problem. Currently is not possible to set active cell to row that does not exists yet. You need to wait until the Ajax is performed, and then set the desired cell in edit mode. I accomplish this by setting a little timeout in order to wait to add the new row and then set the cell in edit mode. See the code snipped:
My suggestion is to use enterEditMode(cell). I have made changes to your project, and hope you will like my approach.
If you have any further questions, please do not hesitate to contact me!
Hi Zdravko Kolev,
I attached an example for you.
Thanks & Regards