Announcement

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

    Setting Checkbox in ListGrid Using Y/N Values

    Hi, I'm trying to set checkbox values in a grid using "Y" and "N" values obtained from a database. We're not using the SmartClient server so cannot use the sqlStorageStrategy value. We're trying to use valueMaps on the checkboxes and we've been able to get them working on a form, but not in a grid. There are no javascript errors or warnings listed in the developer console.

    We're using SmartClient version: "v11.0p_2016-11-15/LGPL Deployment".
    I'm testing with Chrome: Version 69.0.3497.100 (Official Build) (64-bit)

    In our sample form the checkbox chkFormYN works, but the checkboxes in the grid column chkGridYesNo do not load their values correctly.
    Code:
        var dsForm = isc.RestDataSource.create({
            fields: [
                {
                    // Checkbox with values loaded from Y/N source.
                    name: "chkFormYN"
                    , type: "text"
                    , length: "1"
                    , editorType: "CheckboxItem"
                    , valueMap: { "Y": true, "N": false }
                }
            ],
            dataFormat: "json",
            dataURL: "form_data.json"
        });
    
        var form = isc.DynamicForm.create({
            name: "formID"
            , dataSource: dsForm
            , width: 300
            , height: 40
            , fields: [
                {
                    name: "chkFormYN"
                    , type: "boolean"
                    , title: "Test Chk SQL Y/N"
                    , canEdit: "true"
                }
            ]
        });
    
        form.fetchData();
    
        var ds = isc.RestDataSource.create({
            fields: [
                { name: "ID", type: "integer", title: "ID", primaryKey: true, canEdit: "true" }
                , {
                    name: "chkGridYesNo"
                    , type: "text"
                    , length: "1"
                    , editorType: "CheckboxItem"
                    , valueMap: { "Y": true, "N": false }
                }
            ],
            dataFormat: "json",
            dataURL: "grid_data.json"
        });
    
        var grid = isc.ListGrid.create({
            dataSource: ds
            , fields:[
                { name: "ID", canEdit: "true" }
                , {
                    name: "chkGridYesNo"
                    , canEdit: "true"
                    , title: "Test Y/N"
                    , type: "boolean"
                }
            ]
            , top: 45
            , width: 200
            , height: 150
            , showFilterEditor: true
        });
    
          grid.fetchData();
    Our code loads some json data. I'm not sure if there's an easier way to provide a test case that loads this data without loading separate files. The upload mechanism prohibited .json files so I'll list the data here. First grid_data.json.
    Code:
    {    
        "response":{
           "status":0,
           "startRow":0,
           "endRow":99,
           "totalRows":100,
           "data":[
            {
              "ID": 1,
              "chkGridYesNo": "Y"
            },
            {
              "ID": 2,
              "chkGridYesNo": "N"
            },
            {
              "ID": 3,
              "chkGridYesNo": "Y"
            },
            {
              "ID": 4,
              "chkGridYesNo": "N"
            }
           ]
        }
    }
    Finally form_data.json.
    Code:
    {    
        "response":{
           "status":0,
          "data": [
            {
              "chkFormYN": "N"
            }
          ]
        }
    }
    Please advise if there's a simpler way for me to provide a demonstration of the problem.

    #2
    Hi chriss,

    see the transformResponse attribute when creating the RestDataSource for FETCHes.
    See transformRequest attribute when creating the RestDataSource for ADDs/UPDATEs.

    IMHO this is the correct way in your use case.

    Best regards
    Blama

    Comment


      #3
      Many thanks Blama. My apologies for the slow reply while I've been trying this out but it looks good so far.

      Comment

      Working...
      X