Announcement

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

    Adding row to a ListGrid at a specified index using "addAt"

    Hi,
    I'm currently working on a ListGrid that's editable where when a user presses an add a new row button from the tooolbar after selecting a row from the Grid, a new row is supposed to be added based on "addAt"method of RecordList with its index specified. However the row is not getting added and I'm getting a warning message that says

    *15:48:04.373:MUP3:WARN:Log:ResultSets are readonly. This operation (addAt) will be ignored.

    Below is my code where I'm trying to add a blank record at a specified position in the Grid

    marketAddBtn = Buttons.makeToolButton("", "Add", ButtonType.Add, new ClickHandler() {
    public void onClick(ClickEvent event) {

    ListGridRecord rec = new ListGridRecord();
    rec.setAttribute("mid", "352");
    int index=grid.getDataAsRecordList().indexOf(grid.getSelectedRecord());
    grid.getRecordList().addAt(rec, index);

    }
    });

    Can someone please help me to overcome this warning and get the record created?

    #2
    See the Grid Editing overview, especially the section on Handling Unsaved Records. Note that, in addition to the approaches discussed there, you could simply provide your data as a RecordList, which you can freely manipulate since it does not represent a partial cache of a set of remote records from a DataSource.

    Comment


      #3
      Hi Isomorphic,
      I tried some ways to freely manipulate the RecordList data, but I was not able to get the empty records at proper indexes. So if you could assist me in figuring out something related to this warning message- that would be awesome. I'm also attaching the Definition of the ListGrid.

      ListGrid marketseggrid;

      marketseggrid.setOverflow(Overflow.AUTO);

      marketseggrid.setWidth100();

      marketseggrid.setHeight100();

      marketseggrid.setAutoFetchData(true);

      marketseggrid.setCanEdit(true);

      marketseggrid.setSelectionType(SelectionStyle.SINGLE);

      Or if you could provide the link or ways to manipulate the RecordList data using indexes, that would be awesome, thank you for your help!

      Comment


        #4
        Not sure we follow the question. RecordList has an addAt() API, what else could you need to know?

        As far as the warning message, make sure you've read the overviews we pointed you to.

        Comment


          #5
          The issue is addAt() is not able to add ListGridRecord to the ListGrid at the specified index(if used like ListGrid.getRecordList().addAt(ListGridRecord rec, Index index);) and the reason for that is the below warning message

          *15:48:04.373:MUP3:WARN:Log:ResultSets are readonly. This operation (addAt) will be ignored.

          Comment


            #6
            You'll get that message if you use a ResultSet, including having one implicitly created (see listGrid.fetchData() docs). Provide a RecordList and you will not have this message.

            Comment


              #7
              Okay, the issue is solved finally...quite a weird trick...but works for me...
              what you need to do is use grid.setRecords(grid.getRecords()); just before grid.getRecordList().addAt(rec, 0); I think doing this makes the ResultSet editable. Thanks Isomorphic Team.

              Comment


                #8
                That is supplying the data as a RecordList, as we told you to do.

                You are no longer using a ResultSet. Make sure you understand the implications of this: no cache sync, no filtering, etc.

                Comment

                Working...
                X