Announcement

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

    ListGrid populated from two data sources

    Hi there,

    I'm pretty new to SmartGWT so please apologise for the basic question.

    I want to populate a ListGrid from two data sources. Both data sources return "compatible" records, i.e. records with the same fields structure (same number of fields, same field names and same field types). So basically I want to merge the two sets of records coming from the two data sources in order to populate the list grid.
    I have tried doing so by using a third, client-only, data source whose purpose is only to act as a layer between the two original data sources and the grid.
    For a start, and as a simplified example, I just used one original data source (originalDs) to test the layer design (layerDs) and I can't manage to display the data into the grid.

    Code:
    ListGrid grid = new ListGrid();
    grid.SetAuto
    DataSource originalDs = new DataSource();
    //...
    //setting up originalDs here
    //...
    final DataSource layerDs = new DataSource();
    layerDs.setClientOnly(true);
    originalDs.fetchData(null, new DSCallback() {
    	public void execute(DSResponse response, Object rawData, DSRequest request) {
    		layerDs.setTestData(response.getData());				
    		return;				
    	}			
    });
    grid.setDataSource(layerDs);
    grid.fetchData();
    However I can see that the data is actually fetched, indeed, I can see the typical server action window poping up, I have also checked that the data passed to layerDs.setTestData(response.getData()) is accurate, and still, eventually the grid doesn't display anything.
    If I change grid.setDataSource(layerDs) into grid.setDataSource(originalDs) everything works fine...

    Any suggestions either on the example above or on a better way to achieve some data source merging would be greatly appreciated.
    As I said these are my first steps into the framework, I understand that I might have gone the wrong direction by overloading DSCallback.execute(), please then point me to the right direction.
    Thank you,
    - Luc

    #2
    Hi again,

    By searching through the forum's threads I found this link http://forums.smartclient.com/showpo...3&postcount=12 and I tried it. Now my code is as follows :

    Code:
    final ListGrid grid = new ListGrid();
    grid.setAutoFetchData(true);
    DataSource originalDs = new DataSource();
    //...
    //setting up originalDs here
    //...
    final DataSource layerDs = new DataSource();
    layerDs.setClientOnly(true);
    originalDs.fetchData(null, new DSCallback() {
    	public void execute(DSResponse response, Object rawData, DSRequest request) {
    		grid.setData(new ListGridRecord[0]);
    		layerDs.setTestData(response.getData());
    		grid.fetchData();
    		return;				
    	}			
    });
    grid.setDataSource(layerDs);
    grid.fetchData();
    It definitely changed/improved something regarding the grid's cache management system as I can see now that records are added to the grid. I can see that because it's not showing the "No items to show." message anymore and, by adding more and more records, I can distinguish the alternating row colours starting to display.
    But still, the actual data-content of the records doesn't show up...

    Note that the following produces the same results :

    Code:
    layerDs.setTestData(response.getData());
    grid.setData(new ListGridRecord[0]);
    grid.fetchData();
    I guess I have narrowed my question as to the simple issue that is : how to use ListGrid.setTestData(...) properly ?

    Any help would be greatly appreciated.

    Thank you,
    - Luc
    Last edited by dindeman; 15 Dec 2009, 06:42.

    Comment


      #3
      I also found a pretty recent thread from Raistlin80 who was going through a very similar issue. But he seems to have the issue only in browser and not in hosted mode, I'm having this issue in hosted mode though...

      Here is the link : http://forums.smartclient.com/showthread.php?t=8437

      Comment


        #4
        This message is just for the sake of cleaning up this thread that I started more than six months ago (and then forgot about it!)
        So just to say that I found a way to display data coming from two DataSources into one ListGrid (or into one DynamicForm).

        I followed up on another thread with the results of my findings.
        http://forums.smartclient.com/showthread.php?t=9367

        I really hope this will help the community.
        Any other suggestions, either from the Isomorphic team or from other developers would be really interesting too!

        Good luck to all.

        Comment

        Working...
        X