Hello Telerik Team,
I have a grid with in-cell editing enabled and the grid is bound to my DepositDepartment model below. Each DepositDepartment can optionally have a DepositDivision. This DepositDivision can be chosen by the dropdown list I have on the grid. The dropdown list gets its Text field from DepositDivision.Name and the Value field from DepositDivision.Id. I also wire the Save event of the grid, so I can set DepositDivisionId property of the model. I also need to set the DepositDivisionName property as it will be used for display when the cell comes out of the edit mode.
With this setup, everything is working fine except for one specific scenario. If I select "(None)" on the dropdown and get out of the edit cell. The next time go into that cell and try to select some legit DepositDivision, when I come out of the cell, it won't have any effect (it will still show blank). And when that happens, the Save event of the grid won't fire. I've managed to narrow down the issue and found that in the code snippet below, it will somehow determine that the DepositDivisionId property is an observable object after I select the "(None)" option. Specifically, when I select "(None)" (which has empty string as its value) and get out of the edit cell, the grid fires the Save event properly and I set the DepositDivisionId property of my model to empty. So far so good. However, when I try to edit the dropdown again (without saving changes on the grid), the "this.widget.value()" will return null instead of empty. The null value will cause _isObservableObject to be true. And a little further down the value will be replaced by "value = source[idx];". At this point the value variable will be the model corresponding to the grid row instead of just blank. I think this is what causes the this.bindings.value.set(value) to fail and as a result, it won't trigger the Save event of the grid.
The sample project size is slightly large than the attachment limit but you can download it from the external link below.
http://dl.dropbox.com/u/18673670/TelerikSamples.zip
I know this is a very specific issue. So if you need further clarification, please feel free to let me know.
Thank you,
I have a grid with in-cell editing enabled and the grid is bound to my DepositDepartment model below. Each DepositDepartment can optionally have a DepositDivision. This DepositDivision can be chosen by the dropdown list I have on the grid. The dropdown list gets its Text field from DepositDivision.Name and the Value field from DepositDivision.Id. I also wire the Save event of the grid, so I can set DepositDivisionId property of the model. I also need to set the DepositDivisionName property as it will be used for display when the cell comes out of the edit mode.
public
class
DepositDepartment
{
public
int
Id {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
int
? DepositDivisionId {
get
;
set
; }
public
string DepositDivisionName {
get
;
set
; }
/* other fields omitted */
}
public
class
DepositDivision
{
public
int
Id {
get
;
set
; }
public
string
Name {
get
;
set
; }
/* other fields omitted */
}
With this setup, everything is working fine except for one specific scenario. If I select "(None)" on the dropdown and get out of the edit cell. The next time go into that cell and try to select some legit DepositDivision, when I come out of the cell, it won't have any effect (it will still show blank). And when that happens, the Save event of the grid won't fire. I've managed to narrow down the issue and found that in the code snippet below, it will somehow determine that the DepositDivisionId property is an observable object after I select the "(None)" option. Specifically, when I select "(None)" (which has empty string as its value) and get out of the edit cell, the grid fires the Save event properly and I set the DepositDivisionId property of my model to empty. So far so good. However, when I try to edit the dropdown again (without saving changes on the grid), the "this.widget.value()" will return null instead of empty. The null value will cause _isObservableObject to be true. And a little further down the value will be replaced by "value = source[idx];". At this point the value variable will be the model corresponding to the grid row instead of just blank. I think this is what causes the this.bindings.value.set(value) to fail and as a result, it won't trigger the Save event of the grid.
change:
function
() {
var
value =
this
.widget.value();
var
idx, length;
var
field =
this
.options.dataValueField ||
this
.options.dataTextField;
if
(field) {
var
source,
isObservableObject =
this
._valueIsObservableObject;
if
(
this
.bindings.source) {
source =
this
.bindings.source.get();
}
if
(value ===
""
&& isObservableObject) {
value =
null
;
}
else
{
if
(!source || source
instanceof
kendo.data.DataSource) {
source =
this
.widget.dataSource.view();
}
for
(idx = 0, length = source.length; idx < length; idx++) {
if
(source[idx].get(field) == value) {
if
(isObservableObject) {
value = source[idx];
}
else
{
value = source[idx].get(field);
}
break
;
}
}
}
}
this
.bindings.value.set(value);
},
The sample project size is slightly large than the attachment limit but you can download it from the external link below.
http://dl.dropbox.com/u/18673670/TelerikSamples.zip
I know this is a very specific issue. So if you need further clarification, please feel free to let me know.
Thank you,