I am completely new to Kendo UI, so maybe I missing something, but after reading the docs API: http://docs.kendoui.com/api/framework/model it seems Kendo is limited only to work with single ID.
For example, let's say I have a grid in which each row is identified by pair of values (because underlying data have such constraint). So, if I've read it right there is no straightforward way to express this in Kendo?
One workaround I can think of is creating some ad-hoc value which is encoded ids like "value1|value2" (string) and when getting data back from UI, decoding them back.
Is there any more clear way?
Specific example
To focus on something substantial:
http://demos.kendoui.com/web/grid/editing-inline.html
and the relevant code is (from .cshtml file):
.Model(model => model.Id(p => p.ProductID))
in my case it would be (the simplest way I can think of):
.Model(model => model.Id(p => p.ProductComboId1Id2))
where ProductComboId1Id2
is a string encoded as described above.
See at the bottom of the page, it was a problem with Kendo installation. Installer script didn't install one crucial .js file and entire framework went weird. My problem was one of those misbehaviours.
You can use multiple IDs on a single grid. Below I've included syntax for declaring them as well as how to access them via javascript.
Declaration
.Model(model =>
{
model.Id(i => i.ProductID);
model.Id(i => i.ProductID2);
})
Accessing
function GetIDs() {
var itemGrid = $("#GRIDNAME").data("kendoGrid");
var dataItem = itemGrid.dataItem($(this));
var ID1 = dataItem.ProductID;
var ID2 = dataItem.ProductID2;}
function GetID() would be invoked on the grid like this through the row's command column:
columns.Command(command =>
{
command.Custom("Edit").Text("Edit").Click("GetIDs");
command.Destroy();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With