EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
  • 1.  Updating datagrid column

    Posted Mon September 28, 2015 11:32 AM

    I have a data grid that I allows the user to key money into a column to indicate how much money to refund for the line item.

    I can access that inputted information just fine, 

    I would like to perform a calculation on the line and update another field on the same line for the user to see.

    How would I accomplish this?

     

    Rick

     

     

    RickGentner


  • 2.  Re: Updating datagrid column

    Posted Tue September 29, 2015 04:28 AM

    Hi,

    you could try something like this:

     

     

    package test;// RUI Handlerimport com.ibm.egl.rui.widgets.DataGrid;import com.ibm.egl.rui.widgets.DataGridColumn;import com.ibm.egl.rui.widgets.GridLayout;import com.ibm.egl.rui.widgets.GridLayoutData;import com.ibm.egl.rui.widgets.TextLabel;import egl.ui.rui.Widget;////handler test4 type RUIhandler{initialUI =[ui            ], onConstructionFunction = start, cssFile = "css/frommclient.css", title = "test4"}    ui GridLayout{columns = 3, rows = 4, cellPadding = 4, children =[DataGrid            ]};    DataGrid DataGrid{layoutData = new GridLayoutData{row = 1, column = 1}, behaviors =[], headerBehaviors =[],editorBehaviors = [EditorBehaviors], columns =[                    new DataGridColumn{name = "field1", displayName = "Column 1 Header", width = 120},                    new DataGridColumn{name = "field2", displayName = "Column 2 Header", width = 120},                    new DataGridColumn{name = "field3", displayName = "Column 3 Header", width = 120}            ], data =[new Dictionary{field1 = "1", field2 = "3", field3 = ""},                    new Dictionary{field1 = "3", field2 = "5", field3 = ""},                    new Dictionary{field1 = "5", field2 = "8", field3 = ""}]};    function start()    end    function EditorBehaviors(grid DataGrid in, cell Widget in, rowData any in, rowIndex int in, column DataGridColumn in, value any in) returns(Widget)        if(column.name == "field3")            field3_label TextLabel{};            field1 int = rowData.field1 as int;            field2 int = rowData.field2 as int;            field3 int = field1 + field2;                        field3_label.text = field3;            cell.children =[field3_label];        end    endend

     

    Marcel-D


  • 3.  Re: Updating datagrid column

    Posted Tue September 29, 2015 08:17 AM

    I am already using the editorBehaviors to change the a column to a textfield for entry.

    EditorBehaviors only runs at the time the datagrid is rendered.

    I would like to update a row/column value on an already rendered datagrid without having to re-render the entire datagrid.

    RickGentner


  • 4.  Re: Updating datagrid column

    Posted Tue September 29, 2015 08:59 AM

    Hi,

    we used a very tricky way but it works .

    Take a look at this:

     

    package test;// RUI Handlerimport com.ibm.egl.rui.widgets.DataGrid;import com.ibm.egl.rui.widgets.DataGridColumn;import com.ibm.egl.rui.widgets.GridLayout;import com.ibm.egl.rui.widgets.GridLayoutData;import com.ibm.egl.rui.widgets.TextField;import com.triagone.teo.rui.managers.LoginManager;import egl.ui.rui.Event;import egl.ui.rui.Widget;import dojo.widgets.DojoTextField;////handler test4 type RUIhandler{initialUI =[ui            ], onConstructionFunction = start, cssFile = "css/frommclient.css", title = "test4"}    ui GridLayout{columns = 3, rows = 4, cellPadding = 4, children =[DataGrid            ]};    DataGrid DataGrid{layoutData = new GridLayoutData{row = 1, column = 1}, behaviors =[], headerBehaviors =[], editorBehaviors =[EditorBehaviors            ], columns =[                    new DataGridColumn{name = "field1", displayName = "Column 1 Header", width = 120},                    new DataGridColumn{name = "field2", displayName = "Column 2 Header", width = 120},                    new DataGridColumn{name = "field3", displayName = "Column 3 Header", width = 120}            ], data =[new Dictionary{field1 = "1", field2 = "3", field3 = ""},                    new Dictionary{field1 = "3", field2 = "5", field3 = ""},                    new Dictionary{field1 = "5", field2 = "8", field3 = ""}]};    function start()    end    function EditorBehaviors(grid DataGrid in, cell Widget in, rowData any in, rowIndex int in, column DataGridColumn in, value any in) returns(Widget)        if(column.name == "field3")            field3_TextField DojoTextField{onChange ::= field3_TextField_onChange};            cell.children =[field3_TextField];        end    end    function field3_TextField_onChange(e event in)        field3_TextField DojoTextField = e.widget;        cell Widget = field3_TextField.parent;        rowNumber int = cell.getAttribute("row");        DataGrid.data[rowNumber]["field2"] = "1234";        parent1 Widget = e.widget.parent; //        parent2 Widget = parent1.parent; //        parent3 Widget = parent2.parent; //                child1 Widget = parent3.children[rowNumber];        child2 Widget = child1.children[2]; //Number of Field        child3 Widget = child2.children[1]; // --> Textlabel Widget inside of Datagrid        child3.innerText = "1234";    endend

     

    Marcel-D


  • 5.  Re: Updating datagrid column

    Posted Tue September 29, 2015 09:21 AM

    That works exactly as I needed.

    I was headed that way but got frustrated drilling down through the structure in debug.

     

    Thanks

    RickGentner