Hi again,
I have introduced the QueryBuilderComponent placing in columDataQueryBuilder the columns generated same ase the demo where you show the integration, in the constructor we have
class SampleComponent
{
this.query = new Query().select(this.gridQueryBuilderFields)
updateRule(args) {
let predicate = this.qbObj.getPredicate(args.rule);
if ((predicate === null) || (predicate === 'undefined')) {
this.gridInstance.query = new Query().select(this.gridQueryBuilderFields);
}
else {
this.gridInstance.query = new Query().select(this.gridQueryBuilderFields)
.where(predicate);
}
this.gridInstance.refresh();
}
render method..
<QueryBuilderComponent width='100%'
dataSource={this.state.data}
columns={this.columnsDataQueryBuilder}
ruleChange={this.updateRule.bind(this)}
ref={(scope) => { this.qbObj = scope; }}>
</QueryBuilderComponent>
And the current component is
<ButtonComponent cssClass='e-primary'
onClick={this.saveGridSettings}>
Save Settings</ButtonComponent>
<GridComponent ref={grid => this.gridInstance = grid}
dataSource={this.state.data}
id={this.state.id}
query={this.query}
height="400"
modal = {this.state.modal}
allowFiltering={true}
allowPaging={true}
allowReordering={true}
allowRowDragAndDrop={true}
load={this.gridStartup}
allowResize={true}
allowSorting={true}
selectionSettings={this.selectionSettingsModel}
contextMenuItems={this.contextMenuItems}
contextMenuClick={this.onClickContextMenu}
allowReordering={true}
toolbar={this.toolbarOptions}
allowSelection={true}
create={this.onGridCreated}
filterSettings={this.filterSettings}
editSettings={this.editOptions}
columns={this.state.columns}>
<Inject services={[Filter,Sort,RowDD,Page,ContextMenu,Selection, Resize,Reorder, Edit, Resize,Toolbar,Clipboard, ExcelExport, PdfExport]} />
</GridComponent>
</Row>
</Container>
</div>
The component filters correctly following the query builder, but unfortunately the setCellValue doesnt do nothing, the columns have primary key.
This updateGrid get called from a selectEvent from a bootstrap modal where there is a grid where i select things
updateGrid(name, value) {
if ((name == null) || (value == null))
{
throw 'Name and Value of the cell should be provided'
}
console.log("FieldKey " + name + "* FieldValue " +value)
var selectedrowindex = this.gridInstance.getSelectedRowIndexes(); // get the selected row indexes.
var correctGridIndex = selectedrowindex[0]
if (correctGridIndex == null) {
correctGridIndex = 0
}
// in case we are in edit mode we shall exit from them before replacing the selection
var currentName = name
if ((currentName != null) && (value != null)) {
console.log("Close editing" + value)
this.gridInstance.endEdit();
if (!this.state.isEditMode) {
var currentRowGridData = this.gridInstance.getRowsObject()[correctGridIndex].data;
console.log("Close editing" + JSON.stringify(currentRowGridData))
if (currentRowGridData.hasOwnProperty(currentName)) {
console.log("Set cell value")
// currentRowGridData[currentName] = {..value }
this.gridInstance.setCellValue(currentRowGridData.Code, currentName, value)
this.gridInstance.refresh()
}
}
}
}
Any idea?
If i remove the QueryBuilderComponent works.
BR,
Giorgio.