Announcement

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

    ListGrid - adding new record on top

    Hi,

    When adding new record to ListGrid with startEditingNew method it could be useful sometimes to have the possibility to show the new record - while it is unsaved and still edited - on top of the list.
    If we have a list sorted in descending order by some incremental id or creation date , we know that this new record will end up on top after it will be saved. Right now it will scroll down the list to the bottom, load some bottom records and show the form far from the context.

    Best regards,
    Janusz

    #2
    Hi Janusz,

    Assuming we are talking about a scenario where data paging is active, we basically try to keep it on the screen - behavior is described here:

    https://smartclient.com/smartclient-...tePartialCache

    What are you looking for here - perhaps a setting that allows you to rank the different possible insertion points (something like: resultSet.addInsertPosition: ["top", "last", "lastRange"])

    Comment


      #3
      Hi,

      I am talking about graphical placement of new row while it is being edited prior to saving. It has nothing to do with cached data as it happens before new record is submited to server.

      Here is modified sample. I have used "population" to pretend some sequential id that is assigned by server.

      Code:
      isc.ListGrid.create({
          ID: "countryList",
          width:500, height:224, alternateRecordStyles:true,
          // use server-side dataSource so edits are retained across page transitions
          dataSource: countryDS,
          // display a subset of fields from the datasource
          fields:[
              {name:"population", title: "record_id", canEdit: false, formatCellValue:
      function(value, record, rowNum, colNum) {
        if(value == null) return '<i>auto</i>';
      return value;
      }
      },
              {name:"countryName"},
              {name:"continent"},
              {name:"member_g8"},
              {name:"independence"}
          ],
          initialSort: [
             { property: "population", direction: "descending" }
          ],
          autoFetchData: true,
          canEdit: true,
          editEvent: "click",
          listEndEditAction: "next"
      })
      
      isc.IButton.create({
          top:250,
          title:"Edit New",
          click:"countryList.startEditingNew()"
      });
      When you click "Edit New" button, the UI scrolls to bottom and shows form to fill data for new record at the last position behind Canada.
      Because you know that ListGrid is sorted by record_id in descending order, and server will assign id greater then the one for China form to fill data for new record should be shown as the first record before China.

      It could work as an extra parameter in listGrid.startEditingNew(newValues, suppressFocus, newRecordPlacement = 'top' | 'bottom') or some callback that will analize current sort status of listGrid to decide where to show UI for editing new record.
      It would be useful also in very long or slow datasets where loading some last records just for the sake of scrolling listGrid to the bottom could be expensive or slow.

      Best regards,
      Janusz

      Comment


        #4
        Ah - please take a look at the "Handling Unsaved Records" overview here:

        https://smartclient.com/smartclient-...unsavedRecords

        This gives you multiple different techniques to have a new record placed at the top of the grid, or in other locations.

        Comment

        Working...
        X