Grid Select By Id

Thread is closed for posting
16 posts, 1 answers
  1. Andrés
    Andrés avatar
    37 posts
    Member since:
    Jun 2011

    Posted 24 Jan 2012 Link to this post

    Hi all!
    I created this helper function to select rows by id, it works well in FF and Chrome, but not in IE.

    function gridSelectById(gridName, id) {
        var grid = $("#" + gridName);
        var data=grid.data("kendoGrid");
        var row = data.tbody.find(">tr:not(.k-grouping-row)").filter(function (i) {
          return (this.dataset.id == id);
        });
        data.select(row);
      }

    Seems like "dataset" is not defined on the row for IE9. Is this a known issue? Is there a better way of achieving the same result that I'm missing?

    Cheers,
    Andrés
  2. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 24 Jan 2012 Link to this post

    Hello Andrés,

    You can use the following selector to find the row:
    $("#" + gridName).data("kendoGrid").table.find('tr[data-id="' + id + '"]')

    dataset is not supported by InternetExplorer.

    Regards,
    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Andrés
    Andrés avatar
    37 posts
    Member since:
    Jun 2011

    Posted 24 Jan 2012 Link to this post

    Brilliant! That did it. Thank you!
  5. Ilyas
    Ilyas avatar
    6 posts
    Member since:
    Dec 2011

    Posted 03 Feb 2012 Link to this post

    How can i get the Row ID by clicking on it? Actually I want to assign the remote table's row ID to each row of the Grid and by clicking on it, I want to load the second grid. Any solution?
  6. Blop
    Blop avatar
    8 posts
    Member since:
    Jan 2012

    Posted 04 Feb 2012 Link to this post

    Hello IIyas,

    There is samples here :
    PoP
  7. Ilyas
    Ilyas avatar
    6 posts
    Member since:
    Dec 2011

    Posted 06 Feb 2012 Link to this post

    THIS IS Awesome! 
    Is it also possible that parentgrid's one row auto-selected while loading the page? whereas that row's sub-records being shown in the childgrid (childgrid is already done).
  8. Andrew
    Andrew avatar
    9 posts
    Member since:
    Jan 2012

    Posted 05 Mar 2012 Link to this post

    If I use the Q1 12 Beta then the examples above (eg: http://jsfiddle.net/qvKRk/) fail ('dataSource.get(id) is undefined').

    Q1 12 Beta does not support getting the .id from a grid change event as used to be possible. Similarly, using Q1 12 Beta, on code that worked in the previous version using the:
    var row = this.select();
    var id = row.data("id");

    construct now fail. The reason for trying the beta version is to try and get around the issue of a grid failing to resize (http://www.kendoui.com/forums/ui/grid/grid-not-giving-a-height-to-the-content.aspx).

    All I'm trying to do is capture the id of the row that was selected in a grid. It's now wasted stupid amounts of time.

    Please advise when a solution may be available...

  9. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 06 Mar 2012 Link to this post

    Hello Andrew,

    There are some changes in the Grid and DataSource. The data-id attribute is replaced by data-uid. You  can find more details here.

    I've also updated the jsFiddler.
    http://jsfiddle.net/rusev/qvKRk/3/

    Greetings,
    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  10. Andrew
    Andrew avatar
    9 posts
    Member since:
    Jan 2012

    Posted 23 Mar 2012 Link to this post

    Hi,

    Thank you for the response. In the jsfiddle example it now returns a meaningless uid value. How on earth do you get the OrderID value?

    I just don't see why anyone would be interested in something like '09e046a2-26c0-4695-afff-896a28bbbcf0' as a uid when all they were after was an OrderID=1. How does the uid relate to the datasource? Is it some sort of key or something? How on earth do they link togeteher?

    Thanks,
    Andrew
  11. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 26 Mar 2012 Link to this post

    Hello Andrew,

    The uid field is generated and assigned to each record in the DataSource. It is unique for every item and item can be retrieved by this field. This field will be available regardless of the fact if model in defined for the DataSource. In previous version id field was available only if model is defined.

    The following fiddle demonstrates how to retrieve the item by uid from DataSource:
    http://jsfiddle.net/qvKRk/9/

    Greetings,
    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  12. Marko
    Marko avatar
    12 posts
    Member since:
    Apr 2009

    Posted 29 Mar 2012 Link to this post

    Hi,

    How the following fiddle demo should be changed to work with Q1 release

    http://jsfiddle.net/fGrYm/

    Br
    Marko

     

     

     

  13. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 29 Mar 2012 Link to this post

    Hello Marko,

    See the fiddle bellow:
    http://jsfiddle.net/SKxpP/

    All the best,
    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  14. Basem
    Basem avatar
    27 posts
    Member since:
    Dec 2010

    Posted 20 Jun 2012 Link to this post

    What about selecting a row by model id as defined in the dataSource schema?
  15. Brian
    Brian avatar
    8 posts
    Member since:
    Apr 2012

    Posted 03 Jul 2012 Link to this post

    So...I'm wondering a similar thing as Andrew. I have a PK SQL field that's unique and non-null. I wanted to use that as my ID field for each grid row ID. I will have updates being pushed back to me in real time, being able to look up these grid rows by my database key is primary functionality that I need.

    From the JSFiddle demos it looks like what I would need to do is search every row, and check the the get the element in the data set by UID just to try to find the row that my SQL ID corresponds to. Is there any way to do a search with my own ID field that I'm missing? I can't rely on getting the UID from the selected value in the grid because the updates I am pushing may or may not be on the selected item. Is there any way I can associate my own field maybe through templates or some other means?

    Thanks,
    Brian

    Edit: I found this site which goes over templating:
    http://ricardocovo.com/2012/03/26/three-ways-to-get-started-with-kendoui-grids-on-asp-net-mvc/
    It seems to allow adding your own attribute to the row from a remote data source. It seems like I will need to migrate my grids to this for my desired functionality.
  16. Kristoffer
    Kristoffer avatar
    1 posts
    Member since:
    Jul 2012

    Posted 04 Jul 2012 Link to this post

    Here's how I found a row by the datasource id now:

    $("#" + gridName).data("kendoGrid").table.find('tr[data-uid="' + $("#" + gridName).data("kendoGrid").dataSource.get(id).uid + '"]')
  17. David
    David avatar
    17 posts
    Member since:
    Jul 2012

    Posted 27 Jul 2012 Link to this post

    still doesnt explain how to assigned my own GUID to the row as per previous version.

    what if i don't wish to display OrderID, and i just want to add it to the UID field?

    ok found a way:
    var dataRow = $("#grid").data("kendoGrid").dataSource.getByUid(row.data("uid")); 

    datarow contains "id" and another other property you assigned to it.
Back to Top
Kendo UI is VS 2017 Ready