Announcement

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

    Data source on List grid

    Hi,

    I am new to Smart gwt..I am using List grid in my project and was able to display the data properly.I have the following question.

    1)I want to add a filter to my listgrid.So,I enabled the filter as listGrid.setShowFilterEditor(true). But I am setting the data into the listgrid as

    listGrid.setData(records.toArray(new ListGridRecord[records.size()]));

    When i try to search for any data in the filter,its giving me an exception Data source is not set.

    So,i create a datasource class and added my report fields as DataSourceDateField and set the data source as Clientonly...I am not sure if this is the right way to do it?

    2)Is there anyway i can still use the filter option,by setting the Listgrid data in the setData instead of setDataSource?

    Thanks

    Can somebody help me on how to solve this?

    Thanks

    #2
    Did you populate your datasource with any data?

    Comment


      #3
      yeah.After writing the data source class,i am saying as

      data_source.setTestData(records.toArray(new ListGridRecord[records.size()]));
      listGrid.setDataSource(data_source);

      With this approach,the filter works fine,as i am setting the same data in the LIstgrid.setData and listGrid.setDatasource.

      But i am not sure if this is the way we should do it.Is there anyway,we can have the filter taking the data from the data instead of data source?

      Thanks

      Comment


        #4
        That is the way to do it. The filter operates on the datasource data, otherwise you would have to write your own custom filter on the data only in the grid. The data in the grid is really just a visual representation of the datasource. Since your setting the data manually it is just a client only data source.

        Comment


          #5
          Ok.

          In my case,I am getting collection of objects from dao that i am trying to display on the Listgrid,thats why I am using setData.So,are you saying,in these kind of cases,if we want to have a filter on the data we display on the List grid,we will have to have the same data in the datasource and set it as Testdata in the datasource(like the way i did)?

          Thanks

          Comment


            #6
            Yes basically if you want built-in filtering functionality you need a data source, and since your doing a client-only thing you need to populate the datasource, the grid will reflect the datasource data. Although why not setup your DAO as part of the datasource that is the beauty of SmartGWT. Are you doing an RPC call or something else?

            Comment


              #7
              Doing rpc call only.What u mean by setup the dao as part of Data src,how does that works?

              Thanks

              Comment


                #8
                Look through the examples in the showcase under ListGrid-Data Binding, you'll notice many of them has a ds.xml file or coded data source associated with them defining everything and there is no backend call that takes place at all explicitly. The datasource handles all of that. It works with all types of data sources, REST, JSON, plain XML, WSDL, etc.. You just point it to the service serving the data or the database. SmartGWT elimates much of the normal logic you have to write on the backend. For RPC there is an GwtRPCDataSource actually, nice wrapper but you still have to write your own logic to get the data and transform it if needed anyway.

                Comment


                  #9
                  Ok.I actually few bus rules i need to apply in getting the data.So,probably doing thru that thru the data source is not a option.

                  Let me check on the GwtRPCDataSource.

                  Quick google find gave me this,http://forums.smartclient.com/showthread.php?p=44370#post44370

                  is this waht you are talking about?

                  Thanks

                  Comment


                    #10
                    Probably want to look at http://forums.smartclient.com/showthread.php?t=4814&highlight=GwtRpcDataSource

                    It is a long thread so lots of info in there. The code is maintained in the SmartGwtExtensions project, google it, it is in the google code repository.

                    Comment


                      #11
                      Ok.I tried the GWT-RPC DataSource.But i got into the following issue.

                      Looks like the data source is being shared by two different clients,and hence if 2 users are logging into my system,they are seeing the same data(for the second user,its showing the first user data)..How can we fix this.

                      Is it like,we will isolate the data source for each client or we use the same data source and somehow map the data to the client.

                      Thanks

                      Comment


                        #12
                        Hmm, so not sure exactly what your doing then? I mean the datasource is built on the client itself so you don't have two datasources being shared. Now what goes on on the backend is whatever you specify it to be, but the datasource is simply calling the backend and reflecting the data in a widget. Post a little more about what you have going on.

                        Comment


                          #13
                          Originally posted by svjard
                          Hmm, so not sure exactly what your doing then? I mean the datasource is built on the client itself so you don't have two datasources being shared. Now what goes on on the backend is whatever you specify it to be, but the datasource is simply calling the backend and reflecting the data in a widget. Post a little more about what you have going on.
                          So in the case of GwtRpcDataSource, the datasource is on the client-side and the ServiceImpl is on the server side right, so everytime I call the datasource fetchData, the GwtRpcDataSource is making a RPC call to the ServiceImpl.fetchData() which on the server side.

                          This is what I tried, when I accessed the report for accountA I got the results in the ListGrid, in the same session I accessed the report of accoutB I got the same results instead of the DataSource picking up the latest value it returned the same results.
                          Last edited by gwtuser123; 17 Jun 2010, 13:54.

                          Comment


                            #14
                            What triggers accountA versus accountB? I mean how do you let the backend know what to pickup?

                            Comment


                              #15
                              The form has a Select Item which provides the user to pick different accounts like (accountA, accountB), so once the user selects an account and clicks on the View Report button. The onclick Handler of the ViewReport makes a database call and loads the results in an ArrayList. The ArrayList is supposed to be displayed on the ListGrid which is backed by the GwtRpcDataSource so that I can perform, sorting, filtering and pagination of the ArrayList.

                              When ever the user selects a different account the ListGrid always returns the same results.

                              Comment

                              Working...
                              X