Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Problem with advanced criteria for join tables in Smartclient's grid

$
0
0
Hi, all

I'm newbie in OpenBravo and Smartclient , so I'm sorry if I posted obvious question.

I have created a custom MDI view in Openbravo ERP. Added some input field for filtering product's name in Smarclient's listgrid which contains Orders. I have created a Order datasource and bind it to the Smartclient grid. What I want to achieve is to filter a Order list in the grid by product name which is added in the input text field. I tried with several approaches but without success.
So I came to question is it possible to add join table in AdvancedCriteria in the grid's fetchData function?

Here is a snippet of my code:


Code:



    isc.ELB_MainView.addProperties({
      form: null,
      grid: null,
      initWidget: function () {
        this.grid = isc.OBGrid.create({
        setDataSource: function (ds, fields) {
        var selectedFields = [],
        fs = OB.Constants.FIELDSEPARATOR,
        ident = OB.Constants.IDENTIFIER,
        fieldNames = ['documentNo', 'documentStatus', 'orderDate', 'accountingDate',        'businessPartner'+fs+ident, 'currency'+fs+ident],
        i, j;
        for(i = 0; i < fieldNames.length; i++) {
            for(j in ds.fields) {
              if(ds.fields.hasOwnProperty(j) && j === fieldNames[i]) {
                  selectedFields.push(ds.fields[j]);
              }
            }
        }
          this.Super('setDataSource', [ds, selectedFields]);
        this.fetchData();
      }
      });
      this.form = isc.DynamicForm.create({
      fields: [{name : "productName",
              title: "Product Name",
              type : "text",
              width: '100%',
              change: function(form, item, value, oldValue){
                form.main.grid.invalidateCache();
                form.main.grid.fetchData({
                    _constructor: 'AdvancedCriteria',
                    operator: 'and',
                    criteria: {
                      'fieldName': 'orderLineList.product.name',
                      'operator': 'equals',
                      'value': value
                    }
                });
            this.Super('change', arguments);
      }}],
      main: this
      });
   
   
      OB.Datasource.get('Order', this.grid, null, true);
   
    this.addMember(this.form);
      this.addMember(this.grid);
   
    this.Super("initWidget", arguments);
    }

    });

Tnx in advance.
MB

Viewing all articles
Browse latest Browse all 4756

Trending Articles