Announcement

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

    Update of single cell

    I am actually using a listgrid which is bound to a datasource, when the user selects one of the items - it should be "locked" for him - and to present that visually, one of the cells should then show his name.

    The problem is, that i havent found a way to update a single attribute - without reloading the whole datasource - actually tried to use Record.setAttribute("user",theuser) - but that only works with an grid.updateData() - which then results in a fetch !

    Is there any other way to manipulate the Records on the ClientSide??

    #2
    record.setAttribute(), followed by refreshCell for the cell in question.

    Comment


      #3
      Thanks - thats the thing i was searching for (since a day) !

      Comment


        #4
        I tried it out now - but it does not seem to work !

        I also simplified the problem at the first description - as i thought that is not of interest, but the field i want to update has an OptionalDataSource attached (to convert the userid to the username) !

        When i now try to set the attribute of the Record .setAttribute("userId", "1") or .setAttribute("userId","nameOfUser") and afterwards call grid.refreshCell(col,row) no update seems to be performed !

        Can the issue be, that this field has an OptionalDataSource attached - and if yes, how can i achive the update without reloading the whole list ??

        Comment


          #5
          This approach definitely works, and it doesn't matter whether an optionDataSource is present. The only thing we can suggest is that if the field is being edited (via canEdit:true) then you may need to setEditValue() instead, since the editValue (which is an unsaved change) will be shown in preference to the record value. See the ListGrid Editing overview for more details on this.

          Comment


            #6
            when i use grid.refreshRow it works - thats strange, but solves my issue !

            thanks for the help

            Comment


              #7
              one more question to that topic:

              is it also possible to remove an entire Record, without making any DataSource interaction - only hide the Record from being displayed ??

              Comment


                #8
                No, not currently, because with load-on-demand, this introduces a complex situation where visible rows do not correspond to data rows which in turn do not correspond to startRow/endRow values. You can however fetch a complex dataset, pass it to a grid as a RecordList, and be able to manipulate the RecordList (the grid automatically reacts).

                Another pattern is to leave the record in place, but disable it and perhaps use strikethrough styling or similar cues to let the user know it's deleted.

                Comment


                  #9
                  What am I doing wrong, edited value will not be displayed in grid.
                  Also cellHasChanges will not return true.

                  I am using latest 2.5 PowerEdition nightly build from today and the build-in-ds project.


                  @Override
                  public void onModuleLoad() {
                  ListGrid grid = new ListGrid();
                  grid.setWidth(800);
                  grid.setDataSource(DataSource.get("employees"));
                  grid.setAutoFetchData(true);
                  grid.setHeight("50%");
                  grid.setAlign(Alignment.CENTER);
                  grid.setCanEdit(true);
                  // grid.setGroupStartOpen(GroupStartOpen.ALL);
                  grid.setAutoFitData(Autofit.HORIZONTAL);
                  grid.setUseAllDataSourceFields(false);
                  grid.setEditByCell(false);
                  grid.setSaveByCell(true);
                  grid.setEditOnFocus(true);
                  grid.setShowAllRecords(false);
                  grid.setShowRecordComponents(true);
                  grid.setShowRecordComponentsByCell(true);
                  grid.setAutoSaveEdits(false);
                  grid.setFields(new ListGridField("Name"), new ListGridField("EmployeeStatus"));
                  // grid.groupBy("EmployeeStatus");
                  grid.draw();

                  // grid.startEditing(1, 1, true);
                  grid.setEditValue(1, 1, "AAAAAA");
                  // grid.endEditing();
                  grid.refreshCell(1, 1);

                  Comment


                    #10
                    Your setEditValue() calls is fine, code that you aren't showing (probably related to recordComponents) is most likely masking the value. You may, for example, be also creating a recordComponent to show the value, but in retrieving the value to be displayed you are just calling getRecord() rather than getEditedRecord() - see the ListGrid Editing overview and note the distinction the current Record values and the unsaved edits (editValues).

                    Comment

                    Working...
                    X