Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use another property in data element as id

Tags:

slickgrid

I have data elements:

{
    'rid': '1',
    'id': '2',
    'name': 'asdw'
},
{
    'rid': '2',
    'id': '2',
    'name': 'dsddf'
},
{
    'rid': '3',
    'id': '2',
    'name': 'fffgg'
}

Each data element have the same value of "id" property (slickgrid throws me "Each data element must implement a unique 'id' property"). How can i use another property in data element as id (for example "rid")? I can not remove props from data object.

like image 996
Kalinin Avatar asked May 17 '11 10:05

Kalinin


1 Answers

You can try setting your items using the setItems(data, objectIdProperty) method defined on DataView in file slick.model.js.

function setItems(data, objectIdProperty) {
     if (objectIdProperty !== undefined) idProperty = objectIdProperty;
     items = data;
     refreshIdxById();
     refresh();
}
like image 200
Santosh Gokak Avatar answered Oct 14 '22 03:10

Santosh Gokak