i have a grid using a row template to show images. i want to update the data source and have the row template update the row based on the new data. What is the best way to do this?
Hi Ian,
Here is the approach I can recommend:
I'm pasting the suggested script below - you can see a demo of it in the HTML sample I'm attaching to this reply.
var verticalScrollPos; $(function () { $('#grid1').igGrid({ virtualization: false, autoGenerateColumns: false, width: '500px', height: '500px', columns: [ { headerText: "Product ID", key: "ProductID", width: "100px", dataType: "number" }, { headerText: "Units in Stock", key: "UnitsInStock", width: "150px", dataType: "number" }, { headerText: "Product Description", key: "ProductDescription", width: "150px", dataType: "string" }, { headerText: "Unit Price", key: "UnitPrice", width: "100px", dataType: "string" } ], dataSource: namedData, primaryKey: "ProductID", features: [ { name: "Selection", mode: "row" } ], dataBinding: function(evt, ui) { if(ui.owner.scrollContainer()[0]){ verticalScrollPos = ui.owner.scrollContainer().scrollTop(); } }, dataRendered: function(evt, ui) { if(verticalScrollPos) { $(ui.owner.scrollContainer()).scrollTop(verticalScrollPos); } } }); });
Let us know if you need more details.Beast Regards,Borislav
Hi,
I am trying to stop the grid scroll position jumping back to the top when I rebind. Based on this reply I thought I just need to do this:
pos = $("#gridChannelSchedule_scroll").scrollTop();
$("#gridChannelSchedule").igGrid("dataBind");
$("#gridChannelSchedule_scroll").scrollTop(pos);
But pos is always returned as undefined, what am I missing?
Thanks
Ian
Sure :)For things concerning our controls I generally stick to the API reference:http://help.infragistics.com/jQuery/2012.1/ and as for other jQuery magic, I use Google and StackOverflow :)Like in this case, the solution was already described at:http://stackoverflow.com/questions/1805808/how-do-i-scroll-a-row-of-a-table-into-view-element-scrollintoview-using-jquery
thanks. that did the trick. any chance you could point me to documentation with helpful hints like this?
twinfrey said:how do i rebind the data without losing my selected row.
var selectedRowTop; $("#grid1").igGridSelection("selectRow", 19); selectedRowTop = $("#grid1").igGridSelection("selectedRow").element.position().top; $("#grid1_scroll").scrollTop(selectedRowTop);
Hope this helps,Borislav