EGL Development User Group

Expand all | Collapse all

How to position the cursor inside a column in a DataGrid

  • 1.  How to position the cursor inside a column in a DataGrid

    Posted Thu January 21, 2021 12:51 PM
    Masters ..
    Another challenge ..

    I have a dataGrid with 3 textfield columns and several rows where I enter values. However, when an error occurs, I would like to focus on the field where the error occurred.

    Any solution ?

    Hugs and thanks for your attention

    ------------------------------
    Osvaldo Jose de Oliveira Menezes
    Analista
    RellegusTI
    Orlândia
    +55 16 3818-0203
    ------------------------------


  • 2.  RE: How to position the cursor inside a column in a DataGrid

    Posted Fri January 22, 2021 02:42 AM

    Hello,

    Do you really mean you have the widgets inside a DataGrid or maybe inside a GridLayout? 

    In a GridLayout you can use the textField1.focus() to focus on that field, and textField1.select() to select the already entered text. 

    Sometimes this focus option is not working always. That can be fixed by adding a tabIndex=1 

    Example:

    ui Div {
    children =[uiBox, buttonBar],
    tabIndex = 1,
    width = "1000px" };

    Inside a DataGrid you can also add widgets when you are using behavior. Placing the focus on such a field is more complicated.

    Greetings, Jeroen



    ------------------------------
    Jeroen Dielemans
    DMG
    Waalwijk
    ------------------------------



  • 3.  RE: How to position the cursor inside a column in a DataGrid

    Posted Fri January 22, 2021 06:16 AM
    Greetings Jeroen

    In GridLayout I agree and we already use the "tabIndex" and it works correctly. Thank you for the explanation.

    Our problem really is to put the focus on a widget (example TextField) inside the DataGrid.

    What we did and are ready to do so is to list sequentially the "tabIndex" of all rows / columns, and we still set a "setAttribute" with this sequential number.

    Now, how to place the cursor (focus) on one of these columns is still a mystery.

    I await new iterations ...

    Hugs

    ------------------------------
    Osvaldo Jose de Oliveira Menezes
    Analista
    RellegusTI
    Orlândia
    +55 16 3818-0203
    ------------------------------



  • 4.  RE: How to position the cursor inside a column in a DataGrid

    Posted Fri January 22, 2021 09:11 AM
    Edited by Jeroen Dielemans Fri January 22, 2021 09:11 AM

    Hello,

    Okay it is really a DataGrid. We also have this construction at some places in our software.

    It is always possible to read back the existing dataGrid row by row or as in our example we know the row and the column: 

    if (dataGrid1 != null && dataGrid1.getCell(selectedRowNumber, COLOMN_NAME_X) != null)
       w Widget = dataGrid1.getCell(selectedRowNumber, COLOMN_NAME_X).children[1];
       if (w isa TextField)
          (w as TextField).focus();
       end
    end



    ------------------------------
    Jeroen Dielemans
    DMG
    Waalwijk
    ------------------------------