This is a migrated thread and some comments may be shown as answers.
row added event?
4 Answers 238 Views
This is a migrated thread and some comments may be shown as answers.
Levi
Top achievements
Rank 1
Levi asked on 18 Sep 2012, 04:44 PM
Hello,

I have a grid that uses a datasource that calls read() on a timer, so it will continually/auto updated.  I want to highlight new rows added to my grid, which I should be able to do easily if there were a grid row added event, but there doesn't seem to be one.

Any suggestions on how I can go about accomplishing this?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 19 Sep 2012, 06:45 AM
Hello Levi,

On read complete all grid rows are treated as pristine. What that means is that from Grid/DataSource perspective there aren't new rows.

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!
0
Levi
Top achievements
Rank 1
answered on 19 Sep 2012, 02:20 PM
OK, yeah I was thinking about this last night and realized this was probably the case.  The only way I can think of doing this would be to keep track of what I've read from the datasource and compare new data with old, which could probably get very ugly, very fast, and would not be worth the hassle.  Any suggestions if you have them would definitely be appreciated, though!

Thanks for the reply.


0
Nikolay Rusev
Telerik team
answered on 24 Sep 2012, 09:04 AM
Hello Levi,

One way to approach the problem is as in the following sample: http://jsbin.com/umafet/6
Have in mind that there is heavy simulation of new data in the sample above, but the idea remains the same - i.e storing original(prev binding) keys, compare them with the current ones and then highlight the row.

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!
0
Levi
Top achievements
Rank 1
answered on 24 Sep 2012, 01:42 PM
Cool, thanks for the sample code!  Much appreciated!

This was actually very close to what I needed.  Your example appears to highlight old data, while I need to highlight new data.  Here is the change I made:

dataBound: function (e) {
var grid = this;
// get current keys
var keys = $.map(dsTerminalTransactions.view(), function (item) {
return item.id;
});
 
var newkeys= $.grep(keys, function (item) {
return $.inArray(item, origKeys) == -1;
});
 
$.each(newkeys, function (idx, key) {
var uid = dsTerminalTransactions.get(key).uid;
grid.tbody.find("[data-uid=" + uid + "]").css("background-color", "yellow");
});
 
origKeys = keys;
}
Tags
Grid
Asked by
Levi
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Levi
Top achievements
Rank 1
Share this question
or