I have 2 grids on my cshtml. The 'child' is inside a kend-tmpl template.
The nested grid is editable in a popup using an editor template.
Im wondering how do I pass the key of nested grid to the editor template?
The editor template's datasource action is dependent upon the parent key. When editing I can get the key, but only when adding new I am stuck.
Ive looked at 2 ways of doing this. one is with a field default.value on the grid's datasource.Model.Field. Two is on the grid edit event I assign the model's field the value after looking it up.
Option 1: The default value gets passed through but it seems I can only use simple types, hard coded like integers.
model.Field(i => i.PersonID).DefaultValue(222); THIS WORKS
model.Field(i => i.PersonID).DefaultValue("#=PersonKey#"); THIS fails on convert string to int.
model.Field(i => i.PersonID).DefaultValue(new { PersonID = "#=PersonKey#" }); This fails on conversion from anon type
model.Field(i => i.PersonID).DefaultValue("#=PersonKey#");
Option 2: The grid edit javascript function hits and I want to execute this code before the editor template's data.read action is called.
function onEditRequest(e) {
var PersonID = $("#PersonID").val();
//check if record is new
if (e.model.isNew()) {
//set the default value for StateID
e.model.set("PersonID", PersonID);
}
}
The problem is that this function above is not called before the editor template's function (dropdown list datasource .read action)
In fact when debugging in each function it will go back and forth (almost line by line) so there is no guarantee the edit is called before the datasource read (which requires the key)
Any ideas?
The nested grid is editable in a popup using an editor template.
Im wondering how do I pass the key of nested grid to the editor template?
The editor template's datasource action is dependent upon the parent key. When editing I can get the key, but only when adding new I am stuck.
Ive looked at 2 ways of doing this. one is with a field default.value on the grid's datasource.Model.Field. Two is on the grid edit event I assign the model's field the value after looking it up.
Option 1: The default value gets passed through but it seems I can only use simple types, hard coded like integers.
model.Field(i => i.PersonID).DefaultValue(222); THIS WORKS
model.Field(i => i.PersonID).DefaultValue("#=PersonKey#"); THIS fails on convert string to int.
model.Field(i => i.PersonID).DefaultValue(new { PersonID = "#=PersonKey#" }); This fails on conversion from anon type
model.Field(i => i.PersonID).DefaultValue("#=PersonKey#");
Option 2: The grid edit javascript function hits and I want to execute this code before the editor template's data.read action is called.
function onEditRequest(e) {
var PersonID = $("#PersonID").val();
//check if record is new
if (e.model.isNew()) {
//set the default value for StateID
e.model.set("PersonID", PersonID);
}
}
The problem is that this function above is not called before the editor template's function (dropdown list datasource .read action)
In fact when debugging in each function it will go back and forth (almost line by line) so there is no guarantee the edit is called before the datasource read (which requires the key)
Any ideas?