Hi,
I have an MVC project that's using a Databound igGrid to display and edit data. In the Grid definition there's a custom validator for some of the columns defined as:
.Features(feature => {
feature.Updating().ColumnSettings(cs => { cs.ColumnSetting().ColumnKey("ActvtyKey").ReadOnly(true); cs.ColumnSetting().ColumnKey("MetrcTargtNbr").EditorType(ColumnEditorType.Text).Validation(true).EditorOptions("validatorOptions:{checkValue:validate}").Required(false); cs.ColumnSetting().ColumnKey("MetrcInProcssNbr").EditorType(ColumnEditorType.Text).EditorOptions("validatorOptions:{checkValue:validate}").Required(false); cs.ColumnSetting().ColumnKey("MetrcCompltdNbr").EditorType(ColumnEditorType.Text).Validation(true).EditorOptions("validatorOptions:{checkValue:validate}").Required(false); }) .EditMode(GridEditMode.Cell); })
Testing that validator results in an undefined ui.rowID and this is needed as I must look at other cell values within the row being edited to return the validtor result. My validtor function tester is as follows:
function validate(evt, ui) { //this is undefined alert(ui.rowID); //this works alert(ui.value); }
Again, ui.rowID returns undefined and I've also tried ui.rowId. The ui object seems to be there but maybe incomplete as ui.value does return the cell value being edited. Is there something I am missing with the custom validtor definition on the Grid? Please assist as this is very much needed for my project. Thanks!
Thank you, that make sense. I consider this question resolved. Thanks for your help!
Hello C A,
Please note that he custom validator that you're using is based on the igValidator control API and since by default the validator exists as a separate control and it's not related to a grid, hence its events parameters do not provide information about the grid row ID, only information about the validation. The grid updating events, such as "editCellStarted" event, are directly related to the grid itself, therefore they provide information about the row ID. If you have any further questions, please let me know.
Regards,Tsanna
Thank you for your reply. I've tried both methods you pointed out and they work great!
In regards to only the two fields being returned, is this more a limitation of the custom validator or because I'm using the MVC wrapper? I ask because if I use the ui parameter within the igGrid events such as:
grid.on("iggridupdatingeditcellstarted", function (evt, ui) {
alert(ui.rowID);
});
I do get the value. Thanks
Please note that the ui parameter returns only two fields - ui.message and ui.value: http://help.infragistics.com/jQuery/2014.2/ui.igvalidator#events:checkValue . If you want to get the respective row id, then you may access it through: $(ui.owner.element.parent().parent().parent()).attr("data-id") or $(ui.owner.element[0]).closest("tr").attr("data-id")
If you have further questions, feel free to contact me.
Best Regards,Tsanna BelchevaDeveloper Support EngineerInfragistics, Inc.http://es.infragistics.com/support