Can I specify multiple identifiers for a model in the Kendo web interface?

I am completely new to the Kendo user interface, so maybe I missed something, but after reading the API documents: http://docs.kendoui.com/api/framework/model it seems that Kendo is limited only to working with a single identifier.

For example, let's say I have a grid in which each row is identified by a pair of values ​​(since the underlying data has such a restriction). So, if I read it correctly, is there no easy way to express it in Kendo?

The workaround I can come up with is to create some ad-hoc value that encodes identifiers like "value1 | value2" (string) and when receiving data from the user interface, decoding them back.

Is there a clearer way?

Specific example

To focus on something substantial:

http://demos.kendoui.com/web/grid/editing-inline.html

and the corresponding code (from the .cshtml file):

.Model(model => model.Id(p => p.ProductID))

in my case, this would be (the easiest way I can think of):

.Model(model => model.Id(p => p.ProductComboId1Id2))

where ProductComboId1Id2 is a string encoded as described above.

Solution (view)

See the bottom of the page, it was a problem installing Kendo. The installer script did not install one key .js file, and the whole structure became weird. My problem was one of these failures.

+6
source share
2 answers

You can use several identifiers in one grid. Below I have included syntax for declaring them, as well as how to access them through javascript.

Declaration

  .Model(model => { model.Id(i => i.ProductID); model.Id(i => i.ProductID2); }) 

Access

 function GetIDs() { var itemGrid = $("#GRIDNAME").data("kendoGrid"); var dataItem = itemGrid.dataItem($(this)); var ID1 = dataItem.ProductID; var ID2 = dataItem.ProductID2;} 

The GetID () function will be called on the grid, like this, in the command line column:

  columns.Command(command => { command.Custom("Edit").Text("Edit").Click("GetIDs"); command.Destroy(); }); 
+11
source

Perhaps this is a mistake in installing the script, or not, I do not know, but the problem was that the Kendo installer did not install one important file. Namely...

When you install the Kendo package through the NuGet Install-Package KendoIOWeb , it will NOT install the kendo.aspnetmvc.min.js file, and this is one of the key. With it, all suddent, I get a confirmation for deletion, id `are sent via POST instead of GET (exactly how I configured them), the page is displayed after the action, in short - finally, it makes sense.

So, to fix this, do not confuse the code, just download the file with the zip file from the Kendo website, get this file and put it in the content directory.

Since the NuGet installer for Kendo created such a structure Content\kendo\2012.2.710 and below, all the files that I put in this .js file in Content\kendo , so it reminds me that it was manual.

0
source

All Articles