Open ghost opened 10 years ago
Did you look at the source of the examples ? Your JSON must have an 'id' property, as the error says. It's not hard. But you'd need to post a sample of your data here to get any assistance at all.
Here is my json sample [{ "empid": 1, "fname": "John", "lname": "Doe", "email": "jdoe@gmail.com", "sdate": "4/3/2012" }, { "empid": 2, "fname": "Stuart", "lname": "Motzart", "email": "jdoe@gmail.com", "sdate": "4/3/2012" },]
Thanks for giving the reply and the thing is if Iam using ajax call directly it displays nicely with same service url
Just rename "empid" into "id" and it will work. It is what "must implement a unique 'id' property" means.
On Thu, Aug 21, 2014 at 4:15 PM, LavanyaJujjavarapu < notifications@github.com> wrote:
Here is my json sample [{ "empid": 1, "fname": "John", "lname": "Doe", "email": "jdoe@gmail.com", "sdate": "4/3/2012" }, { "empid": 2, "fname": "Stuart", "lname": "Motzart", "email": " jdoe@gmail.com", "sdate": "4/3/2012" },]
— Reply to this email directly or view it on GitHub https://github.com/mleibman/SlickGrid/issues/990#issuecomment-52911637.
great it works but grid is displaying data is not populated
this is my code what's the problem here and onrowschanged and onrowscountchanged functions are nott fired dataView = Slick.Data.DataView(); dataView.beginUpdate(); dataView.setItems(obj); dataView.endUpdate();
grid = new Slick.Grid("#teamGrid", dataView, columns, options);
dataView.onRowsChanged.subscribe(function (e, args) {
grid.invalidateRows(args.rows);
grid.render();
});
dataView.onRowCountChanged.subscribe(function (e, args) {
grid.updateRowCount();
grid.render();
});
Firstly, try to compare your code to one of the examples in repository. If still nothing seems wrong, make a jsfiddle http://jsfiddle.net/ example - it would be much easier to help you after that.
On Thu, Aug 21, 2014 at 4:36 PM, LavanyaJujjavarapu < notifications@github.com> wrote:
this is my code what's the problem here and onrowschanged and onrowscountchanged functions are nott fired dataView = Slick.Data.DataView(); dataView.beginUpdate(); dataView.setItems(obj); dataView.endUpdate();
grid = new Slick.Grid("#teamGrid", dataView, columns, options); dataView.onRowsChanged.subscribe(function (e, args) { grid.invalidateRows(args.rows); grid.render(); }); dataView.onRowCountChanged.subscribe(function (e, args) { grid.updateRowCount(); grid.render(); });
— Reply to this email directly or view it on GitHub https://github.com/mleibman/SlickGrid/issues/990#issuecomment-52913520.
You do not need to rename empid to id. When you set the items in setItems function, you can specify the id property.
setItems(items, "empid")
This is the definition of setItems function.
function setItems(data, objectIdProperty) {
if (objectIdProperty !== undefined) {
idProperty = objectIdProperty;
}
items = filteredItems = data;
idxById = {};
updateIdxById();
ensureIdUniqueness();
refresh();
}
On Aug 21, 2014, at 7:18 AM, ldmberman notifications@github.com wrote:
Just rename "empid" into "id" and it will work. It is what "must implement a unique 'id' property" means.
On Thu, Aug 21, 2014 at 4:15 PM, LavanyaJujjavarapu < notifications@github.com> wrote:
Here is my json sample [{ "empid": 1, "fname": "John", "lname": "Doe", "email": "jdoe@gmail.com", "sdate": "4/3/2012" }, { "empid": 2, "fname": "Stuart", "lname": "Motzart", "email": " jdoe@gmail.com", "sdate": "4/3/2012" },]
— Reply to this email directly or view it on GitHub https://github.com/mleibman/SlickGrid/issues/990#issuecomment-52911637.
— Reply to this email directly or view it on GitHub.
If these two functions are not executing means problem with json data?
dataView.onRowCountChanged.subscribe(function (e, args) { grid.updateRowCount(); alert("hi"); grid.render(); });
dataView.onRowsChanged.subscribe(function (e, args) { grid.invalidateRows(args.rows); alert("bye"); grid.render(); });
When I bind json data to slick using dataview it shows above error what is the problem here can any one help me