Hierarchical Data Provider and filter function

clock November 10, 2010 04:27 by author Flexicious

Question -> If you apply a filter, it doesn’t refresh the whole tree, it just removes the child records but leaves all the parent items on the grid. Is there a way to remove the parent items as well?

OR

-> Is there a way to filter/hide a parent node if all of its children have been filtered in a hierarchy advanced data grid?

Answer -> For this, you will need to add an additional filter function. Flexicious will then tack on the filter function to its built in filter. See attached example.


HierarchicalFilterFunction.mxml (7.01 kb)

 

In another blog post, we demonstrate how to update summary footers on basis of the filtered data.

Please note, this is only for the ExtendedAdvancedDataGrid, not for Ultimate, for Ultimate, you have the enableRecursiveSearch and enableHideIfNoChildren properties that automatically implement this functionality for you.



Select All CheckBox, Row Selection, Flexicious Customization

clock November 8, 2010 01:18 by author Flexicious

We often get questions from our customers in regards to this topic, and this blog post aims to summarize what we have received so far, and show you how to implement scenarios that we do not support out of the box, but show you how to extend our product to implement such scenarios. Some questions that we attempt to answer in this post:

1) How do I preselect checkboxes in the SelectAllCheckBoxHeaderColumn.

2) How do I highlight/unhighlight rows when checkboxes are selected (In other words, how can we ensure the selected rows and checkboxes are in synch)

3) How do I disable/enable checkboxes for selection

4) What is the difference between selectedobjects. selectedkeys, and selectedItems

First, let's tackle question 4, since it involves a little theory:

If you use Flexicious in filterPageSortMode=client, this really does not apply to you, but in server mode, each page of data potentially represents a brand new dataprovider. Let's assume you have a Database table of 100,000 records, with the pageSize property set on Flexicious to 50. You load page 1, select a few items, and move on to page 2. The SDK datagrid exposes a property called selectedItems, which will be lost when the new page of data is loaded. This is why we have the selectedObjects and selectedKeys property, that is, to keep the selection that was loaded in memory on prior pages of data. Now, in most LOB applications, each record can be identified by a surrogate key (or some unique identifier). This surrogate key is then used to uniquely identify different instances of at the same Object. For example, when the page 1 is loaded for the first time, there is a Employee OBJECT with EmployeeId=1. When the user selects this record, navigates to a different page, and switches back to page 1, the Employee with ID 1 is still there, and need to stay selected, but it could be an altogether different INSTANCE of the same record in the database. This is why we have the selectedKeyField property, which would in this case, be "EmployeeID" so we can uniquely identify the selection made by the user across multiple pages.

Lets' quickly tackle question 3, because it's rather straightforward. All you have to do is to extend the SelectAllCheckBoxItemRenderer class, and use the extension as the item renderer for the SelectAllAdvancedCheckBoxHeaderColumn or SelectAllCheckBoxHeaderColumn. See ExtendedCheckBoxItemRenderer in the attached project for an example, where we disable the checkbox if the number=7 (As an example).

Now, moving on to question 1 - We've covered this before, but you basically need to add the item you want selected to the selectedObjects collection. You also want to add the "Key" to be selected to the selectedKeys collection. And then, you need to call the invalidateList() method. In the attached example, In the creation complete method, we call the newObject method, that adds 10 items to the data provider, and adds all even items to the selected keys as well as the selected objects collection. Now, when all is done, we also call the dgTest_selectedKeysChangedHandler manually, to synchronize the checkbox selection with the key selection, which brings us to question 2, that is how to synchronize the checkbox selection with the row highlight. This is a little more complicated. This is not a feature that is supported out of the box by our product, but one of our customers needed this and utilized our consulting services to implement this for them. We are glad to share a part of that work with all our customers in the attached demonstration project.:

First, we created an Extended version of the Extended DataGrid and the Extended Advanced DataGrid, called MyDataGrid and MyAdvancedDataGrid respectively. In these classes, we overrode the mouseDownHandler function, to not select/deselect the rows when the checkbox column is clicked. Second, we added event handlers for the selectedKeysChanged as well as the change methods. In each of these methods, we synchronize the "Other", that is, when selected keys are changed, we update the selectedITems/selectedObjects, and when the selectedItems are changed, we update the selectedKeys. Third, we set the selectionMode property on the AdvancedDataGrid to "multipleRows"or if you are using the Classic DataGrid, we set the allowMultipleSelection=true. Now if you run the project, you will see that when you select the checkboxes, the rows are hightlighted, and when you click on the row, the checkboxes are selected. This is a little complicated, but possible nonetheless. We often engage in short assignments like this one via our consulting services division, where within a few hours of customization work, we are able to quickly implement customizations that would otherwise take a lot longer for our clients to implement themselves.

 

Please Note: To use the attached project, you will need to drop your licensed copy of the library into the libs folder.

As an FYI, a lot of what this code does is try to get around the limitations of the architecture since we inherit from the Adobe SDK base. Our Ultimate product handles this much more elegantly without the need for any additional code on your part.

Project.zip (22.61 kb)