jQWidgets Forums
jQuery UI Widgets › Forums › Plugins › Data Adapter › Consistency in source properties
Tagged: dataadapter
This topic contains 5 replies, has 2 voices, and was last updated by Peter Stoev 11 years, 3 months ago.
-
Author
-
Hello,
I have an issue with properties case. In current documentation, there are all in lower cases but I had mixed case from an older version (I have just written a wrapper).
Consider this code:
var source = { localdata : scope[params.data], datatype : "json", datafields : params.columns }; var dataAdapter = $jqwidgets.dataAdapter().get(source);
I don’t provide all code but it’s not necessary. It should work properly, but it doesn’t.
This data adapter is used to create a grid and while grid is properly displayed, events are not working at all.To correct this issue, I changed datafields to dataFields. No rendering change, and events are now working.
On a side note, here is my old code (still working perfectly):
var dataAdapter = new $.jqx.dataAdapter({ localData : scope[params.data], dataType : "json", dataFields : dataFields });
I guess there has been a change in property case in a recent release, but still a compability code between old and new version. But somehow, there is probably an issue, something is still using the old code.
Now, because I use a wrapper, I can provide both cases but it would be better to use the correct one.Hi,
The following is invalid code and has always been invalid code:
var dataAdapter = $jqwidgets.dataAdapter().get(source);
If you look at the Grid’s demos you will notice that all source properties are lower case. I do not know which events you mean. jqxDataAdapter does not have events. It has callback functions and they were always with camel case i.e loadComplete, loadError, etc. Nothing is changed in recent releases about that.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThe code you mentioned is a wrapper, but the source properties are untouched.
var getDataAdapter = function(source, settings) { source.datafields = getDatafields(source.datafields); var params = angular.extend({}, dataAdapterOptions, settings); return new $.jqx.dataAdapter(source, params); };
I meant events related to jqGrid component. For some reasons, they don’t get fired if my data adapter used datafields (like in documentation) instead of dataFields (which must be a previous version since I had it in my code).
In my case, I am catching event related to cell click:
iElement.on("cellClick", function(event) { event.stopPropagation(); $scope.$apply(function() { var item = $scope[params.data][event.args.rowindex]; params.events.cellClick($scope.$parent, item, event.args.columnindex); }); });
All this code works perfectly when my data-adapter use dataFields property, but not with datafields.
Hi aigleborgne,
The event is called “cellclick”, not “cellClick” and it works as expected on our side. That is also visible from our online demos and API Documentation demos in jSFiddle. Ex: http://jsfiddle.net/jqwidgets/HB3Cb/. The array is called datafields and the “cellclick” event works.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI will test this, but it has certainly changed because all my code are copy&paste from documentation and live demo, and I did this a few months ago. The fact that it is working when dataFields and cellClick are in camel case confirm my point, doesn’t it ?
Thank you for your support !
It does not. The event was always called cellclick not, cellClick. If you used it incorrectly and it worked due to some strange reason, I do not know, but in the documentation, the event is documented as cellclick and that has not changed.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.