Announcement

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

    Error in adding data to resultSet

    Hi,

    I'm using smartGWT version 2.4 and want to add data to ListGrid's resultSet in following sample:
    Code:
    final ResultSet rs = new ResultSet();
    rs.setDataSource(getDataSource());
    rs.setFetchMode(FetchMode.PAGED);
    rs.getRange(0, 10);
    rs.addDataArrivedHandler(new DataArrivedHandler() {
    @Override
    public void onDataArrived(DataArrivedEvent event) {
      ListGridRecord operationRow = new ListGridRecord();
      rs.add(operationRow);
      setData(rs);
    }
    });
    In code above I recieve following JavaScript error: this.addAt is not a function

    Removing operations also thows error, when I create ResutSet manually the errors occur.

    What do I wrong? How should be data in result set changed?

    Thanks.

    Michal

    #2
    Use DataSource.addData() to add data to the DataSource and it will be reflected in the ResultSet. If what you want is actually to modify a dataset in memory without sending updates to the server, consider either a RecordList or a clientOnly DataSource.

    Also, wrong forum - we'll move the thread.

    Comment


      #3
      thanks for answer and sorry for putting message to wrong forum.

      I want to add data to the list grid with RestDataSource that is related to server's services so I can't not use addData on dataSource becuase it'll crated server request.

      I used it also with RecordList as you recommended but with the same effect:
      Code:
      grid.getRecordList().add(new ListGridRecord());
      returns javascript errror this.addAt is not a function, why that error occurs?

      is there any way how to add data to grid without creating new ResultSet with former data and new data items?

      Thanks

      Comment


        #4
        Provide a RecordList to the grid via setData() to enable local changes which are not sent to the DataSource. See also listGrid.saveLocally.

        Comment


          #5
          that works correctly, but sorting is executed only on client and invoke no request to server, even I explicitly set it to grid:
          Code:
          ResultSet resultSet = new ResultSet();
          resultSet.setFetchMode(FetchMode.PAGED);
          resultSet.setUseClientFiltering(false);
          resultSet.setUseClientSorting(false);
          this.setDataProperties(resultSet);
          when I set data by recordList, filtering goes to server but sorting no, also I didn't find sort listener to handle it, is there any solution how to meet my requirements and still keep server sorting and filtering?

          thanks

          Comment


            #6
            If you add a record to a paged dataset, that changes the client rowNums by one. If the server doesn't know about this, paging won't work. Think very carefully about your requirements - as stated they don't make much sense because the server is going to need to know about these extra records in order to return the expected data with paging enabled.

            Comment


              #7
              I'm trying to implement following paging listGrid:
              - first request will retrieve first page of data (10 items) and then I add there button 'more data' to grid - as last row of table
              - when user click on 'more data' button, data stays in table, in background is invoked request to retrieve next data page and these data are added to table
              - if there are other data on server, 'more data' button is again added

              I implemented it as ListGrid with RestDataSource and server side filtering and sorting, and when next page of data is received I added it as manually created ResultSet/RecordList to table, all works fine except sorting.

              how do you recommed to implement it?

              Thanks a lot for help.

              Comment


                #8
                We don't really recommend implementing that at all. The default behavior (scroll down to reveal more rows) is simpler.

                Comment


                  #9
                  yes, I agree with you but there are such requirements

                  Is it possible to add data on client side to grid with server fetch, filtering and sorting with keeping server as data storage?
                  Do I have some possibility to influence sorting behaviour in way of forcing server requests?

                  if you say it's impossible, we'll try to change requirements.

                  thanks,

                  Comment


                    #10
                    It's not impossible or even especially difficult, but we see it as a waste of effort (extra time spent for a poorer UI) and we would recommend showing the built-in UI to whomever is requesting this UI so that they can see that something better is already in the framework.

                    In the meantime, sorry, we can't help further with something like this unless you purchase a support package.

                    Comment


                      #11
                      Hi,

                      we paid support package,

                      please, give me an advice how to implement such table,

                      thanks,

                      michal

                      Comment


                        #12
                        First, just want to reiterate that we really don't recommend implementing your UI this way. It's just a worse UI with much poorer performance, and will cause you to write and maintain a bunch of extra code to achieve it. If you show your end users the way the built-in UI works, we think it's very likely they will prefer that, and then you can avoid extra effort to make something worse.

                        The next step down this road is to add a SortChangedHandler, go to the server to fetch newly sorted data via sending a DSRequest through your RestDataSource with a sortBy direction specified, and then replace the RecordList with the new set of rows.

                        Comment

                        Working...
                        X