I have a grid which has three columns:
- The first one is just text, not editable.
- The second one is an <input>, should be editable.
- The third one is a kendoDropDownList, should be editable.
My dataSource, with the two fields I want to be editable marked as such:
var
dataSource =
new
kendo.data.DataSource({
// Omitted for brevity
schema: {
model: {
id:
'row'
,
fields: {
row: { type:
'number'
, editable:
false
},
type: { type:
'number'
, editable:
false
},
description: { type:
'string'
, editable:
false
},
// First column
quantity: { type:
'number'
, editable:
true
},
// Second column
reason: { type:
'number'
, editable:
true
}
// Third column
}
}
}
});
My kendoGrid, with editable: 'incell':
$(
'#grid'
).kendoGrid({
dataSource: dataSource,
editable:
'incell'
,
columns: [
{
title:
'Description'
,
field:
'description'
},
{
title:
'Quantity'
,
field:
'quantity'
,
editable:
function
(e) {
return
false
; },
template:
'<input type="text" id="quantity_#= row #" class="k-textbox" value="#= quantity #" />'
},
{
title:
'Reason'
,
field:
'reason'
,
editable:
function
(e) {
return
false
; },
template:
'<select id="reason_#= row #" name="reason_#= row #" class="reasoncombo" />'
}
]
// Omitted for brevity
});
I set editable: function (e) { return false; } to both columns I want to edit so it doesn't use the native editor.
The documentation reads The JavaScript function executed when the cell/row is about to be opened for edit. The result returned will determine whether an editor for the column will be created.
Now my issue is whenever I change the value of an <input> or select another value from a kendoDropDownList, those fields are not updated and marked as dirty in the dataSource.
I even tried to add `data-bind:"value:quantity"` to the template of my <input>, no luck.
Here is a working fiddle for test purposes.
Is there a way to edit fields without the native editor?
PS: I should add that if I change editable: function (e) { return false; } to return true instead, my <input> and kendoDropDownList get changed to the native editor when clicked and changing values in the editor works just fine, though this is not what I want.