Announcement

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

    [BUG] ListGrid filterEditor's SelectItem doesn't display selected criteria

    Hi, Isomorphic,
    we found strange behavior of ListGrid when tried programmatically filter a list with fetchData(), on filter, SelectItem haven't shown a filtered option, so after some debugging we've found that bug is in SelectItem.js:
    Code:
        _valueIsValid : function (value) {
                    
            if (this.addUnknownValues || this.optionDataSource) return true; // <- this.optionDataSource is undefined when 'foreignKey' is used. must be this.getOptionDataSource() here.
    SelectItem.optionDataSource is null when used 'foreignKey', but this.getOptionDataSource() correctly returns.


    proof of concept:

    Code:
    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <meta http-equiv="Cache-control" content="no-cache">
        <title></title>
    
        <script>var isomorphicDir = "smartclient/";</script>
        <script src=smartclient/system/modules-debug/ISC_Core.js></script>
        <script src=smartclient/system/modules-debug/ISC_Foundation.js></script>
        <script src=smartclient/system/modules-debug/ISC_Containers.js></script>
        <script src=smartclient/system/modules-debug/ISC_Grids.js></script>
        <script src=smartclient/system/modules-debug/ISC_Forms.js></script>
        <script src=smartclient/system/modules-debug/ISC_DataBinding.js></script>
        <script src=smartclient/skins/EnterpriseBlue/load_skin.js></script>
    
    </head>
    <body>
    <script>
        var optionsDataSource = isc.RestDataSource.create({
            ID: "optionsDataSource",
            clientOnly: true,
            fields: [
                {hidden: true, primaryKey: true, name: 'id', type: 'sequence', required: false},
                {name: 'name', type: 'text'}
            ],
            testData: [
                {id: 1, name: 'insert'},
                {id: 2, name: 'update'},
                {id: 3, name: 'remove'}
            ]
        });
    
        var ds = isc.DataSource.create({
            clientOnly: true,
            fields: [
                {name: 'test', type: 'text', editorType: 'SelectItem', foreignKey: 'optionsDataSource.id'}
            ],
            testData: []
        });
    
        var listGrid = isc.ListGrid.create({
            width: 700,
            showFilterEditor: true,
            dataSource: ds,
            fields: [
                {
                    name: 'test',
                    filterEditorProperties: {
                        autoFetchData: false,
                        addUnknownValues: false
                    }
                }
            ]
        });
    
        ////FAST FIX:
        //var selectItem = listGrid.filterEditor.getEditFormItem('test');
        //selectItem.optionDataSource = selectItem.getOptionDataSource();
    
        listGrid.fetchData({test: 2}) // FilterEditor doesn't show a selected value. should be: 'update'
    
    </script>
    </body>
    </html>

    #2
    Hi antanas.arvasevicius,

    I see two problems with your testcase. Could you change them and see if the error still occurs? I agree that I'd also expect the FilterEditor to show a value.
    • optionsDataSource.id is primaryKay and also required: false. IMHO this combination does not make sense.
    • ds.test is of type text and points via foreignKey to optionsDataSource.id, a sequence (=number) field. This also does not make sense.
    I don't know if those two are the reasons for the behavior you are seeing, but I don't think that this is a valid test case currently.

    Best regards
    Blama

    Comment


      #3
      It's not related at all. Problem is that SelectItem.'foreignKey' is not supported alone, I must also explicitly state a SelectItem.optionDataSource, but it's not logical, why then "foreignKey" would be used for? And I see that "getOptionDataSource()" return a correct datasource by lookup from "foreignKey" so I think they missed this line of code after some refactoring or so.

      Updated test case:

      Code:
      <!DOCTYPE html>
      <html>
      <head lang="en">
          <meta charset="UTF-8">
          <meta http-equiv="Cache-control" content="no-cache">
          <title></title>
      
          <script>var isomorphicDir = "smartclient/";</script>
          <script src=smartclient/system/modules-debug/ISC_Core.js></script>
          <script src=smartclient/system/modules-debug/ISC_Foundation.js></script>
          <script src=smartclient/system/modules-debug/ISC_Containers.js></script>
          <script src=smartclient/system/modules-debug/ISC_Grids.js></script>
          <script src=smartclient/system/modules-debug/ISC_Forms.js></script>
          <script src=smartclient/system/modules-debug/ISC_DataBinding.js></script>
          <script src=smartclient/skins/EnterpriseBlue/load_skin.js></script>
      
      </head>
      <body>
      <script>
          var optionsDataSource = isc.RestDataSource.create({
              ID: "optionsDataSource",
              clientOnly: true,
              fields: [
                  {hidden: true, primaryKey: true, name: 'id', type: 'sequence'},
                  {name: 'name', type: 'text'}
              ],
              testData: [
                  {id: 1, name: 'insert'},
                  {id: 2, name: 'update'},
                  {id: 3, name: 'remove'}
              ]
          });
      
          var ds = isc.DataSource.create({
              clientOnly: true,
              fields: [
                  {name: 'test', type: 'integer', editorType: 'SelectItem', foreignKey: 'optionsDataSource.id'}
              ],
              testData: []
          });
      
          var listGrid = isc.ListGrid.create({
              width: 700,
              showFilterEditor: true,
              dataSource: ds,
              fields: [
                  {
                      name: 'test',
                      filterEditorProperties: {
                          autoFetchData: false,
                          addUnknownValues: false
                      }
                  }
              ]
          });
      
          //FAST FIX:
      //    var selectItem = listGrid.filterEditor.getEditFormItem('test');
      //    selectItem.optionDataSource = selectItem.getOptionDataSource();
      
          listGrid.fetchData({test: 2}) // FilterEditor doesn't show a selected value. should be: 'update'
      
      </script>
      </body>
      </html>

      Comment


        #4
        Thanks for the notification and analysis.
        We see the problem, agree with your take on it, and are getting a fix in today

        Regards
        Isomorphic Software

        Comment

        Working...
        X