Grid Select By Id

1 Answer 7110 Views
Grid
This question is locked. New answers and comments are not allowed.
Andrés
Top achievements
Rank 1
Andrés asked on 24 Jan 2012, 07:37 AM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 24 Jan 2012, 08:51 AM
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!
Andrés
Top achievements
Rank 1
commented on 24 Jan 2012, 08:56 AM

Brilliant! That did it. Thank you!
Ilyas
Top achievements
Rank 1
commented on 03 Feb 2012, 04:05 PM

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?
Blop
Top achievements
Rank 1
commented on 04 Feb 2012, 07:48 AM

Hello IIyas,

There is samples here :
PoP
Ilyas
Top achievements
Rank 1
commented on 06 Feb 2012, 12:09 PM

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).
Andrew
Top achievements
Rank 1
commented on 06 Mar 2012, 03:33 AM

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...

Nikolay Rusev
Telerik team
commented on 06 Mar 2012, 09:22 AM

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!
Andrew
Top achievements
Rank 1
commented on 24 Mar 2012, 03:18 AM

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
Nikolay Rusev
Telerik team
commented on 26 Mar 2012, 09:27 AM

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!
Marko
Top achievements
Rank 1
commented on 29 Mar 2012, 10:05 AM

Hi,

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

http://jsfiddle.net/fGrYm/

Br
Marko

 

 

 

Nikolay Rusev
Telerik team
commented on 29 Mar 2012, 10:23 AM

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!
Basem
Top achievements
Rank 1
commented on 20 Jun 2012, 03:44 PM

What about selecting a row by model id as defined in the dataSource schema?
Brian
Top achievements
Rank 1
commented on 03 Jul 2012, 01:29 PM

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.
Kristoffer
Top achievements
Rank 1
commented on 04 Jul 2012, 02:09 PM

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 + '"]')
David
Top achievements
Rank 1
commented on 27 Jul 2012, 08:23 AM

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.
Tags
Grid
Asked by
Andrés
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or