Announcement

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

    [13] ListGrid - Fieldstate vs viewstate

    Hi there,
    we have a problem with the ListGrid in the latest Smartclient 13-Build
    We have used the fieldStateChanged when the viewState of the ListGrid changed, but this method contains no sort information. So we changed to the viewStateChanged which includes the sort information. We thought that the viewStateChanged behaves otherwise the same as fieldStateChanged. But with the viewStateChanged we have the problem that the resizing of the columns does not behave in the same way as fieldStateChanged. With the viewStateChanged only the width of the last adjusted column is passed to the viewState. The width of columns that have been modified before will not be passed to the viewStat.
    Is there any possibility to get both information, the sort information and the resizing of the colums like in fieldStateChanged in the viewState?


    Sidenote: We are removing the "selected" and "open" attributes from the viewstate.
    Also we do calculate the absolute widths of the colums to a percentage-width for each field.
    Code:
    function viewStateWithPercentageWidths(usePercentage, viewState, gridName) {
        var grid = isc.Canvas.getById(gridName);
        var gridWidth = grid.getWidth();
        if (usePercentage) {
            viewState = viewState.replace(/\"width\":(\d*(\.\d*)?)/g, function (s, aWidth) {
                var percentageWidth = "\"width\":";
                if (aWidth != "") {
                    percentageWidth = percentageWidth + "\"" + ((parseInt(aWidth) / gridWidth) * 100) + "%\"";
                }
                return percentageWidth
            });
        } else {
            viewState = viewState.replace(/\"width\":\"(\d*(\.\d*)?)\%\"/g, function (s, aWidth) {
                var realWidth = "\"width\":";
                if (aWidth != "") {
                    realWidth = realWidth + Math.ceil((parseFloat(aWidth) * gridWidth) / 100)
                }
                return realWidth
            });
            viewState = "(" + viewState + ")"
        };
        return viewState
    }
    viewStateChanged -> only the last width but with sorting
    Code:
    viewState: {
       "field":[
          {
             "name":"fieldOne",
             "autoFitWidth":false
          },
          {
             "name":"fieldTwo",
             "autoFitWidth":false
          },
          {
             "name":"fieldThree",
             "autoFitWidth":false,
             "width":"43.10776942355889%"
          }
       ],
       "sort":{
          "sortSpecifiers":[
             {
                "property":"fieldOne",
                "direction":"ascending"
             }
          ]
       },
       "hilite":"[No Hilites]",
       "group":"[No Grouping]",
       "showFilterEditor":false
    }
    fieldStateChanged -> no sorting but all widths
    Code:
    viewState: {
       "field":[
          {
             "name":"fieldOne",
             "autoFitWidth":false,
             "width":"4.385964912280701%"
          },
          {
             "name":"fieldTwo",
             "autoFitWidth":false,
             "width":"34.08521303258145%"
          },
          {
             "name":"fieldThree",
             "autoFitWidth":false,
             "width":"34.21052631578947%"
          }
       ],
       "sort":"[No Sorting],"hilite":"[
          No Hilites
       ]","group":"[
          No Grouping
       ]","showFilterEditor":false}
    Best regards

    #2
    Hi SimonF,

    you have grid = isc.Canvas.getById(gridName). Can't you just call grid.getViewState()?

    Best regards
    Blama
    Last edited by Blama; 24 May 2023, 02:12.

    Comment


      #3
      hi SimonF

      Can you show the setup for your ListGrid? No need for data - in particular, we're interested in your state-changed handlers and any settings related to field-width or auto-fitting at the grid or field level, which can affect viewState content.

      thanks

      Isomorphic Support

      Comment

      Working...
      X