This is a migrated thread and some comments may be shown as answers.

Kendo Datasource new data sync color row

5 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mirza
Top achievements
Rank 1
Mirza asked on 15 Jun 2013, 12:50 PM
can i check what is new data on sync?i have this:
$('#order_it').click(function(){
    gridNewData.sync(); // this will send data to server
});

gridNewData complete:
complete: function(xhr, textStatus) {
    if (textStatus == 'success') {
        orders.read(); // this will refresh orders, and grid too, a
        gridNewData.data([]); // empty that temp datasource
    }
}

and:
var orders = new kendo.data.DataSource({
    autoSync: false,
    transport: {
        read: {
            contentType: 'application/json',
            url: '/dokument/orders/',
            dataType: 'json',
            complete: function(xhr, textStatus) {
 
                // i think that here i need to get new synced items(or uids)
 
            }
        }
    },
    schema: {
        model: {
            id: 'id'
        }
    }
});

I need to make that rows in grid with another color, but can't find way to check what is new data.

Thanks.

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 18 Jun 2013, 02:16 PM
Hello Mirza,

I am not sure if I understand correctly the needed functionality. Are you updating the items or reading the data again? If you are reading the data then I can suggest to use the Grid dataBound event to apply the styles. The same event should be triggered after synchronizing the items. When updating the items, you could also use the sync dataSource event to get the new data.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mirza
Top achievements
Rank 1
answered on 18 Jun 2013, 11:19 PM
Can you please give me example?
0
Daniel
Telerik team
answered on 20 Jun 2013, 03:35 PM
Hello,

I created a small jsBin example that shows how the dataBound event can be used.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mirza
Top achievements
Rank 1
answered on 20 Jun 2013, 07:27 PM
This is great, but how can i check which one is new?
Example:

var orders= new kendo.data.DataSource({
    autoSync: false,
    batch: true,
    transport: {
        read: {
            url: '/rest/racun/',
            dataType: 'json'
        }
    },
    schema: {
        model: {
            id: 'id',
            fields: {
                konobar: { type: 'number' },
                sto: { type: 'number' },
                objekat: { type: 'number' },
                narucilac: { type: 'string' }
            }
        }
    }
});
$('#list').kendoListView({
    dataSource: orders,
    template: kendo.template($('#orders').html()),
    dataBound: function(e){
        var view = this.dataSource.view();
        for(var i = 0; i < view.length;i++) {
            if (view[i].isNew()) {
                console.log('new');
            }
        }
    }
});
$('#check').click(function(){
    orders.read();
});
Now i load page, and add new row in db from admin panel, so there is new data, then click 'Check' button, and it load all data, but doesn't show me 'new' message in console.
Any suggestion? What am i doing wrong here?
0
Daniel
Telerik team
answered on 24 Jun 2013, 03:45 PM
Hello again,

The changes will already been synchronized in the dataBound event so the records will no longer be new. You could use the requestEnd event and check the response from the server when a create request has completed to get the new items. 

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Mirza
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Mirza
Top achievements
Rank 1
Share this question
or