Hello,
"selectRow " method right now accepts only row number. How can I find it if I know primary key value for that row? Basically, I want to select row by its primary key value.
I have a checkbox selector and I'm selecting the items on the rowsRendered event. (igGrid, IgniteUI 13.1.20131.2143) This is how I'm doing it:
rowsRendered: function (evt, ui) { //Knockout ViewModel, but it could just be an array var boundModel = viewModel.selectedItems; var gridId = ui.owner.id(); //For each of my saved selected items //select the checkbox on the grid for (var i = 0; i < boundModel().length; i++) { //the item's primary key var key = boundModel()[i].Id; for (var x = 0; x < ui.owner.rows().length; x++) { //the row contains the key on an attribute data-id="primarykey" var rowKey = ui.owner.rows()[x].getAttribute("data-id"); if (key == rowKey) { $('#' + gridId).igGridSelection('selectRow', x); } } } }
Is there any way to get this to work when you have a checkbox selector on a row? I can find the rowIndex correctly but since I'm using checkbox selectors it doesn't seem to like selectRow
Hey,
Only rows which are rendered can be programatically selected. If you select something from the tree, which will cause re-binding & rerendering of data which isn't currently rendered, it isn't possible at the moment.
I will add a feature request about having a scrollTo(index / key) API, which we can add in the near future.
Thanks for the feedback, it's valuable functionality.
Angel
Martin, thank you for that example.
But still, I need to clarify one thing. In our solutions very often we have such situation - there are 2 controls on the screen, a tree and a grid. User checks items in the tree and then rows are added to the grid. There could be up to several thousand rows in the grid so visualization is essential. Also when user select item in the tree corresponding row should be selected and scrolled into the view. So, the question is - is it possible to achieve this with current version of Infragistics components or maybe such functionality will be added in the nearest future? I'm asking because right now we're evaluating 3rd party controls to use in the our upcoming ASP.NET MVC project.
Thanks.
Hi adogg,
Attached you can find complete example for selecting row by primary key in igGrid. I've rewritten the function, but I can't guarantee that it is faster, because I still use jQuery selectors and index function. Keep in mind that this approach works only for rendered rows which means that it will work in igGrid virtualization mode, but only for rendered rows.
If your row doesn't get selected it probably is not rendered in the grid yet(if you use virtualization).
Hope this helps,
Martin Pavlov
Infragistics, Inc.