Question

I'm newbie in a OpenBravo ERP system, so I'm sorry if I posted an 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:

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.

Was it helpful?

Solution

Similar question is posted on SmartClient Forum about Joining tables for listgrid datasource.

Here is my solution that will definitely solve your problem:

Create a view that is created by joining tables required for grid and use it as data source

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top