ExtJs4 Mapping a treeStore level to a Store - model-view-controller

What is a good way to map a level of a treestore to a flat store. In my case,
I want to group criteria for a search. All search criteria are inserted into the top level of the treeStore, unless they are grouped, in which case they become children of a top level logical(AND or OR) node. So, within a grid, I want to display the top level nodes (via some toString method I will define in the model). This is the easy part, I just go through the top level of my tree and generate the output for the Store/grid. However, when I want to remove something from the grid/store, it also needs to be removed from the treestore which represents the actual logical structure.
So, How can I keep track of which textual store item corresponds to which top level node in my treeStore?

Load your data onto the store or treegrid (but not both), then collect the records from one object and just add them to the other (using store.add() or treestore.getRootNode().appendChild()). At this point if you have a reference to the record, you can just say store.remove([record]); and then treestore.getRootNode().removeChild(record); to remove it from both.

Related

Power BI - Matrix Drill-down Causes Upper Level in Hierarchy to Disappear

I am working with a client new to Power BI, and they complain that when drilling down to the next level, the level above "disappears" showing only the parent of the drill-down records, as shown here:
Top Level Shows All Records
After drill-down, we see the next level down, but only the parent record at the level above:
Here, the lower drill-down records appear, but only their parent appears from the level above.
My client would like the hierarchy to still display the parent levels while expanding only the one child level they are interested in viewing the detail for. I know that entire levels can be expanded at once, but is there a way I can create a matrix that allows the behavior the client is looking for?
Can I drill-down in a Power BI matrix to a lower level while leaving the level above displayed in its entirety?
You should use Expand to the next level, instead of drill down. This should do the work. Try it and let me know if this is the case.
You may find this useful https://learn.microsoft.com/en-us/power-bi/desktop-matrix-visual

Kendo treeView Server Filtering with Load on demand

I want to have something similar to the example here http://demos.telerik.com/kendo-ui/treeview/filter-treeview-in-dialog but with some changes which are
Server side filtering
remote datasource
Load on demand true (when no search)
For example, the expected behaviour is initially the tree will be loaded from remote datasource with load on demand (only first level will be retrieved) and when user enter a search text, the search will be performed on server side and all results will be returned and no lazy loading. last thing when user clear search text, the tree will return to lazy loading again and load on demand would be true.
And here are more details about my case
Tree Structure will be only two levels, let say type and item
root level is fixed, all roots will always shown
first json object structure which will be used in all data retrieval will be
Id
Description
HasChild
Childs
so data will be retrieved from the server as following
first load will be the root level only, has child will be true for all roots, and children will be null
when expand node (with lazy loading), only return the children for the expanded node
when search (will not lazy loading), return all roots with matched children in children property
Any ideas?
as Ross Bush says, it is not a built in functionality, after a lot of tries and research, i found that the issue is two things:
I cannot change the load on demand after initialization (even i use setOptions function)
I cannot change the value of children after datasource intialized !!!
so, the solution (or acutally a workaround) is re-intialize the datasource and the tree when i change the mode from search to view and vise versa !!!. this is how i solved it
Thanks all for your contributing

How to invalidate parts of a hierarchy (tree) of data in Redis cache

I have some product data that I need to store multiple versions of in a Redis cache. The data is made up of JSON-serialised objects. The process of obtaining the plain (basic) data is expensive, and the process of customising it into different versions is also expensive, so I'd like to cache all versions to optimise wherever possible. The data structure looks something like this:
BaseProduct
/\
/ \
/ \
/ \
/ \
CustomisedProductA CustomisedProductB
/ \ / \
CustomisedProductA1 CustomisedProductA2 CustomisedProductB1 CustomisedProductB2
The general idea here is:
There is a base product stored in a database.
One level of customisation can be applied to this product - e.g. information about a specific version of this product for a sales region.
A second level of customisation can be applied within that - e.g. information about this product at a particular store within a region.
The data is stored in this way because each step of the data retrieval/calculation process is expensive. The first time a particular product is retrieved for a region, there will be one set of customisations performed to make it into a region-specific product. The first time a particular product is retrieved for a store, I need to perform customisations based on the regional product to generate the store-specific product.
The problem comes in due to the fact that I may need to invalidate data in a few ways:
If the base product data changes, then the whole tree needs to be invalidated and everything needs to be regenerated. I can achieve this by storing the whole structure in a hash and deleting the hash by its key.
If the first set of customisations for a product change (i.e. the middle level), then I need to invalidate the nodes underneath this level too. For example, if the customisations for CustomisedProductA are affected by a change, I need to expire CustomisedProductA, CustomisedProductA1, and CustomisedProductA2.
If the second set of customisations for a product change (i.e. the bottom level), then that node needs to be invalidated. I can achieve this in a hash by calling HDEL key field (e.g. HDEL product CustomisedProductA:CustomisedProductA1).
My question is therefore: is there a way of representing this type of multi-level data structure, to allow for the performance of storing the data in multiple levels while enabling invalidation of only parts of the tree? Or, am I limited to expiring the entire tree (DEL key) or specific nodes (HDEL key field) but nothing in between?
There are at least 3 different ways for doing that, each has its own pros and cons.
The first approach is to use non-atomic ad-hoc scanning of the tree to identify and invalidate (delete) the tree's 2nd level (1st set of customizations). To do that, use a hierarichal naming scheme for your Hash's fields and iterate through them using HSCAN. For example, assuming that your Hash's key name is the product's ID (e.g. ProductA), you'd use something like '0001:0001' as the field name for the first customization's first version, '0001:0002' for its second version and so forth. Similarly, '0002:0001' would be the 2nd customization 1st version, etc... Then, do find all of customization 42's versions, use HSCAN ProductA 0 MATCH 0042:*, HDEL the fields in the reply, and repeat until the cursor zeros.
The opposite approach is to proactively "index" each customization's versions so you can fetch them efficiently instead of performing the Hash's full scan. The way to go about that is using Redis' Sets - you keep a Set with all the field names for a given product's version. Versions can either be sequential (as in my example) or anything else as long as they are unique. The cost is maintaining these indices - whenever you add or remove a product's customization and/or version, you'll need to maintain consistency with these Sets. For example, the creation of a version would be something like:
HSET ProductA 0001:0001 "<customization 1 version 1 JSON payload"
SADD ProductA:0001 0001
Note that these two operations should be in a single transaction (i.e. use a MULTI\EXEC block or EVAL a Lua script). When you have this set up, invalidating a customization is just a matter of calling SMEMBERS on the relevant Set and deleting the versions in it from the Hash (and the Set itself as well). It is important to note, however, that reading all members from a large Set could be time consuming - 1K members isn't that bad, but for larger Sets there's SSCAN.
Lastly, you could consider using a Sorted Set instead of a Hash. While perhaps less intuitive in this use case, the Sorted Set will let you perform all the operations you need. The price for using it, however, is the increased complexity of O(logN) for adding/removing/reading compared to the Hash's O(1), but given the numbers the difference isn't significant.
To unleash the Sorted Set's power, you'll use lexicographical ordering so all of the Sorted Set's members should have the same score (e.g. use 0). Each product will be represented by a Sorted Set, just like with the Hash. The members of the Set are the equivalents of the Hash's field, namely customizations' versions. The "trick" is constructing the members in a way that allows you to perform range searches (or level-2 invalidations if you will). Here's an example of how it should look like (note that here the key ProductA isn't a Hash but a Sorted Set):
ZADD ProductA 0 0001:0001:<JSON>
To read a customization version, use ZRANGEBYLEX ProductA [0001:0001: [0001:0001:\xff and split the JSON from the reply and to remove an entire customization, use ZREMRANGEBYLEX.

jqgrid - treegrid for flat structure data

I have my data stored in database in flat structure with out any heirarchical fashion and currently displaying in tabular format using jqgrid. I would like to display it in drill down fashion like the count at the top levels, child levels like this in nested fashion. Is it possible to do using jqgrid...
I think that the best way to make some queries used GROUP BY on the server side to construct the information about the hierarchy of the data. In the way you will be construct the tree structures which you need. The main data will get isLeaf:true, level:4, expanded:false, loaded:true properties and parent property with the id of the parent node "2200". If you would use as ids the values with prefixes like 'e' for 'Event', 'm' for 'Model' and so on you will be easy construct unique ids for every row so you will be able to construct all data for the Tree Grid on the server and then place the data in the server response.
Alternatively you can fill only the top level of the tree grid. You can construct simply query which will produce the resulting set. If the user will opens some tree node the new request will be sent to the server. The request will contains the some additional parameters: nodeid, parentid and n_level. If you good choose the id values of on the root items you will have full information to construct query which will get you the next level on the tree. You should use parentid as to construct the WHERE part of the query. In the way you can also construct the tree and load all noded on-demand.

How can I show a flat representation of a GtkTreeStore in a GtkTreeView?

I have a TreeStore with objects that I view and manipulate through a GtkTreeView/GtkTreeModel setup.
I also have a TreeView showing a TreeModelSort of the TreeStore, which I use for sorting on columns like name and date.
The problem is, that the sort mechanism only sorts the root nodes, even if a underlying child node has e.g. a date that is later/sooner than the roo tnodes' dates.
So, the question is if there is any way to show the objects as a List, not a tree, but keeping the references to the paths in the other TreeView?
I would suggest a TreeModelFilter that filters out any rows that are child rows (ie, depth > 1). You can filter your sorted model, and display just the root nodes.

Resources