Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to clear criteria after fetch data for tree grid successfully?

    Hi All!

    I have a "company" list grid and a "company relationship" tree grid. I want to implement the flow like "if user select the company on the company list will change the datasource and fetch the data for the tree grid component by matching the companyId", Now the problem I am facing is that I can fetch the corresponding company data in tree grid successfully, but when I try to open the root folder in the tree grid, it shows nothing even though it has child records. Also, I found the following message in console:

    === 2008-09-09 20:23:59,421 [or16] DEBUG RPCManager - Request #1 (DSRequest) payload: {
    criteria:{companyId:"8055505", groupId:"8055505"},
    operationConfig:{dataSource:"relation", operationType:"fetch"},
    appID:"builtinApplication",
    operation:"relation_fetch",
    oldValues:{companyId:"8055505", groupId:"8055505"}
    }

    === 2008-09-09 20:23:59,436 [or16] INFO SQLDriver - [builtinApplication.relation_fetch] Executing SQL query on 'HSQLDB': SELECT relationship AS "relationship", groupId AS "groupId", capitalBase AS "capitalBase", financialExposure AS "financialExposure", transaction AS "transaction", shareholding AS "shareholding", companyId AS "companyId", companyName AS "companyName" FROM relation WHERE (companyId='8055505' AND groupId='8055505')

    As you can see in the above message, the companyId that I used to fetch tree data for company list still exist in the criteria, that should be the reason why I can't retrieve the child record for the root record successfully. So how can I clear the companyId from the criteria after fetch data for tree grid successfully? so that I can retrieve the child record for the root record successfully.

    Thanks in advance
    Vinson

    #2
    Hi Vinson,
    If you need to change the criteria applied to a DataBound listGrid or TreeGrid you can simply call 'fetchData()' with the new criteria.
    This will throw away the current set of data and fetch a new set of data that matches the criteria.
    I'm not sure if this really resolves your problem. If not any additional information you could give us to help understand what you're trying to achieve / how your data is structured etc would be very helpful.

    Thanks
    Isomorphic Software

    Comment


      #3
      Thanks for you reply fisrt

      My data structure is as following:
      1. I have a "company" list which stroe the basic informations for the company.
      2. I have another "company relationship" list, it should be a tree grid structure and it stroes the relationship of the company. for example, B company belong to A company and C company belong to A company too, as following shown.

      Company A
      |- Company B 30%
      | |- Company E 51%
      |- Company C 60%


      Now, everything I want to do is when I select "A company" in the "company" list, a correspoding tree stucture like above chart shown should be shown in the "company relationship" tree grid. Now I can retrieve the record "A company" in the tree grid, but when I try to open the "Company A" node folder, It shows nothing under the "Company A" node folder, Just because the old criteria (companyId) still exist in the current criteria like the following shown:

      === 2008-09-09 20:23:59,436 [or16] INFO SQLDriver - [builtinApplication.relation_fetch] Executing SQL query on 'HSQLDB': SELECT relationship AS "relationship", groupId AS "groupId", capitalBase AS "capitalBase", financialExposure AS "financialExposure", transaction AS "transaction", shareholding AS "shareholding", companyId AS "companyId", companyName AS "companyName" FROM relation WHERE (companyId='8055505' AND groupId='8055505')

      I also found that when I try to open the "Company A" node folder, tree grid will do the "fetch" operation with of the old criteria (companyId='8055505' AND groupId='8055505') every time. but it won't call the "fetchData()", so that I can't make use of the new criteria to do the fetchData() again. so, as you can see, if I can remove the "companyId='8055505' " from the criteria, I think my problem can be resolved immediately.

      Thanks again
      Vinson

      Comment


        #4
        Hi xml-vinson,

        The criteria you pass to fetchData() are passed with every subsequent fetch - this is by design, so you can, for example, select multiple unrelated trees from a single DataSource.

        There's a few ways to do what you want, but they all boil down to overriding dataSource.transformRequest() to customize the criteria, which will arrive as dsRequest.data in that function. You could, for example, add the companyId as criteria only when you find the criteria empty or find that it contains the rootValue for the tree, indicating the first fetch is being performed.

        Note that the dsRequest contains dsRequest.parentNode and dsRequest.resultTree when a TreeGrid/ResultTree is using a DataSource, as in your case. These might be useful to you.

        Comment

        Working...
        X