6 Answers, 1 is accepted
0
Nohinn
Top achievements
Rank 1
answered on 20 Sep 2012, 11:45 AM
You could change them via javascript if you only want to set a property with an unique value.
Though you will have to do some work on it:
Though you will have to do some work on it:
- first if you're using batch editing mode you will have to place a selector column (with chechbox), if you're not using the batch editing mode then you have the multiple select option.
- you will have to loop the selected items, get their dataItem, change the value and send the new updated dataItem to the grid:
for
(
var
i = 0; i < selected.length; i++) {
var
dt = g.dataItem(selected[i]);
dt.property =
true
;
g._modelChange({field: "property", model: dt});
}
0
Michael
Top achievements
Rank 1
answered on 20 Sep 2012, 04:08 PM
Nohinn. So I'm trying what you've suggested. Im trying to set a textual value in the cell. Im using something like dt.property = "hello". When I rung this cells in the grid indcate that they have been changed but the value remains the same. And when I click the save changes nothing gets submited.
0
Michael
Top achievements
Rank 1
answered on 20 Sep 2012, 04:37 PM
Apologies. I had a mistake in the code and can now change the value in the cells which is great. But when I click on the 'save' in the toolbar it doesn't submit the changes.
0
Accepted
Nohinn
Top achievements
Rank 1
answered on 20 Sep 2012, 04:46 PM
You could try and force those items to be dirty so they look like to be updated:
http://jsbin.com/afuzoh/1/edit
Let me know if this fixes your issue.
http://jsbin.com/afuzoh/1/edit
Let me know if this fixes your issue.
0
Michael
Top achievements
Rank 1
answered on 20 Sep 2012, 05:25 PM
Thanks Nohinn! That works.
Question, as I was searching around I saw some references to some code like
Is this also another possible way to set a cell value? I couldn't get it to work though.
Outside the grid I tried something like:
Question, as I was searching around I saw some references to some code like
var
model = dataSource.get(id);
model.set(
"foo"
,
"bar"
);
// changes model foo field's value to bar
Is this also another possible way to set a cell value? I couldn't get it to work though.
Outside the grid I tried something like:
var grid = $("#grid").data("kendoGrid");
var
model = grid.dataSource.get(id);
model.set(
"foo"
,
"bar"
);
// changes model foo field's value to bar
0
Nohinn
Top achievements
Rank 1
answered on 21 Sep 2012, 08:04 AM
Yes, you can do it this way too:
With the getByUid, getting it from the tr data-uid attribute, and then setting the correct format value (string, number, ...)
P.S: Here you have the previous sample updated using this way http://jsbin.com/afuzoh/2/edit
var
grid = $(
'#grid'
).data(
'kendoGrid'
);
var
model = grid.dataSource.getByUid(
"UidValue"
);
model.set(
"Property"
, value);
With the getByUid, getting it from the tr data-uid attribute, and then setting the correct format value (string, number, ...)
P.S: Here you have the previous sample updated using this way http://jsbin.com/afuzoh/2/edit