jQWidgets Forums
jQuery UI Widgets › Forums › TreeGrid › Does the treegrid really databind???
Tagged: treegrid
This topic contains 7 replies, has 3 voices, and was last updated by Peter Stoev 10 years, 8 months ago.
-
Author
-
I can successfully have the treegrid bind with local data. However, if I take the original source and remove X rows or change data values, then do a databind, nothing changes.
dataSource = dataSource.slice(1, 4);
dataAdapter.dataBind();I can see on the “beforeLoadComplete” event that there are fewer rows. I can Firebug the UI and change something, and the record reverts back to the original state.
Basically I want to rebind the treegrid with the code above, and see data changes bound. The pagination would obviously update with their new values based on the data.
Why isn’t this working?
Hi yoitsme,
You can learn how to bind the TreeGrid from this help topic: http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxtreegrid/jquery-treegrid-data-sources.htm and from all the available demos about jqxTreeGrid available on our website. You can’t rebind the widget using such code. You can rebind the widget when you set it to point to a new instance of dataAdapter or when you bind the dataAdapter to a remote data source and call the widget’s updateBoundData. method. According to me, dataSource.slice(1, 4); would just update some local array and that’s it. It would not affect the dataAdapter or its source. May be, if you use such approach you will have to update the source object’s localData source.localData = ….
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/This really isn’t data binding. In true data binding, when the source is updated, the destination is also updated. There should be no need to call a updateBoundData method. In fact, this breaks the data binding paradigm, and requires a significant effort on the part of the UI to ensure synchronicity in the UI and the data source. So unless I am misunderstanding the way data binding works in jqWidgets, there’s a serious flaw in the data binding.
Here’s an angular example of why I feel this is terrible, especially for grids (and especially for tree grids):
var myData = [{name: 'First record'}, {name: 'Second record'}]; var ds = { localData: myData }; var dataAdapter = new $.jqx.dataAdapter(ds); $scope.gridSettings = { columns: [{text: 'Name', dataField: 'name', width: 100}], source: dataAdapter } myData[1].name = "I want to change my name";
In the case above, you need to actually call $(‘#treeGrid’).jqxTreeGrid(‘updateBoundData’); if you want your tree grid to reflect the changes to myData[1]. When the updateBoundData method is called, the entire grid is refreshed and loses its state. This means, in the tree grid, any rows you have expanded or collapsed will not be remembered. The developer is entirely responsible for tracking the state of the grid. This entirely defeats one of the main purposes of data binding.
So unless I am misunderstanding how data binding is actually supposed to work, so far the jqWidget framework does not seem to handle data binding correctly.
Hi tjdo,
The data binding is supposed to work in the way it works now. It is clearly explained in the examples and documentation how to use this widget and other widgets and how to synchronize with their data sources. I am sorry if that is not enough for you. I don’t know how you think that the widget will understand that you changed a property somewhere in your source unless you point the widget that something has changed somewhere. May be you used to work with .NET or other similar Framework where you can track such changes, but in JavaScript this is not possible.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Really? Because data binding works like that in Angular, Knockout, and almost any other framework I’ve worked with to date that supports data binding.
Hi tjdo,
You probably then heard about Scopes, Watches and Observables in these frameworks which internally track for changes. In general that’s what made these frameworks famous. Ok, I am not going to argue with you and that’s not my point. If you wish, use this widget. It is clearly explained how to use it and how to Data Bind it and We think that Data Binding works correctly in our Widgets. I am sorry, that you expect something else or you think that we should make changes in our framework to handle some changes somewhere automatically. If you do not like our approach, then I suggest you to find a different framework which works in a different way.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/After spending two weeks with the framework API, it’s pretty good. I probably could have gotten around the API issues. But after spending as much time reading the forum it’s apparent you guys really need improvement on the customer service side. We are refactoring a very large an enterprise application that is likely going to require significant support from the chosen component vendor for the next couple of years, so I think I’ll look at other frameworks. Thanks for the time.
Hi tjdo,
We will take your notes into account.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.