ListView on Change, get "primary key" for selected item

2 posts, 0 answers
  1. Jillian
    Jillian avatar
    16 posts
    Member since:
    Aug 2011

    Posted 25 Jul 2013 Link to this post

    I have a list view that has a change event.  When an item in my list view is selected how can I get the "key" that i set for the item instead of the text displayed?

    <script type="text/x-kendo-tmpl" id="ItemTemplate">
      <div style="margin:5px;">
        #:ItemNo# - #:Description#<br />
    <%: Html.Kendo().ListView<ItemList>()
    .Name("Items")<br>  .TagName("div"
     .DataSource(ds =>
         ds.Read(read => read.Action("ItemListRead", "Home"))
           .Model(m => m.Id(i => i.ItemKey)))
     .Selectable(s => s.Mode(ListViewSelectionMode.Single))
     .Events(events => events.Change("onChange"))

    <script type="text/javascript">
       function onProjectItemChange(e) {
          var selected = $.map(, function (item) {
             return $(item).text();

  2. Dimiter Madjarov
    Dimiter Madjarov avatar
    2211 posts

    Posted 29 Jul 2013 Link to this post

    Hello Jillian,

    To achieve this you could get the uid of the selected item through the data-uid attribute and use the getByUid method of the DataSource to retrieve the model for it.
    function onChange(arg) {
        var selected =;
        var model = this.dataSource.getByUid(selected.attr("data-uid"));

    I hope that this was the information that you were looking for. I wish you a great day!


    Dimiter Madjarov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top