Make cell/row editable if all columns are readOnly

Posted by: moritz.neugebauer on 15 September 2020, 10:50 pm EST

    • Post Options:
    • Link

    Posted 15 September 2020, 10:50 pm EST

    Dear Wijmo Team,

    I need to make all cells of a row editable, even though all columns of the grid are readOnly.

    The solution of this thread doesn’t work out for me, because the beginningEdit event isn’t fired when I click on a cell of a column that is readOnly.

    https://www.grapecity.com/forums/wijmo/flexgrid-how-to-make-a-par

    I already achieved to change the appearance of a single row to look like it is editable when all columns are set to be readOnly but I was not able to make the cells editable.

    
    flexdata.formatItem.addHandler((s: wjcGrid.FlexGrid, e: wjcGrid.FormatItemEventArgs) => {
    ...
    
    if(item.isEinzelwertbearbeiter) {
                        let classes = e.cell.classList;
                        classes.remove(disabledCell);
                    }
    
    ...
    }
    
    

    How can I achieve that?

    Best regards

    Moritz

  • Posted 16 September 2020, 4:22 pm EST

    Hi Moritz,

    If the whole column is read-only, then all the rows in that column will not be editable. To fulfill your requirements, you can handle the selectionChanging event of the FlexGrid and set the current column as editable according to the row. Please refer to the sample link below for reference:

    https://stackblitz.com/edit/angular-d27kah

    Regards,

    Ashwin

  • Posted 21 September 2020, 5:40 pm EST

    Dear Ashwin,

    thank you for your answer. Using the onSelectionChanging method works well for me. Is there a way to detect if the row is a new row? I would like to change the readOnly property for a row that is added to the grid.

    My requirement is basically like this:

    • Make certain cells of a new row editabled
    • After the row is saved to the grid, make it readOnly.

    Best regrads

    Moritz

  • Posted 22 September 2020, 8:41 pm EST

    Hi Moritz,

    You use the index property of the row to check whether it is a template of new row or an actual data row. Please refer to the updated sample link below for reference:

    https://stackblitz.com/edit/angular-v159f4

    ~regards

  • Posted 27 September 2020, 6:45 pm EST

    Dear Ashwin,

    is it possible to undo the change of readOnly property as soon as the user selects another row?

    Let’s say the user selected the second row and therefore column three is set to be editable. Now the user selectes the fifth row where column three has to be readOnly again. How can I achieve that?

    Currently, when I set column three to be editable, it is editable “forever”.

    Best regards

    Moritz

  • Posted 28 September 2020, 8:06 pm EST

    Hi Mortiz,

    That is why I suggested using the selectionChanging event. In my earlier sample, if you will edit the row with Japan, it will be editable but as soon as you select any other cell in the same column, you will not be able to edit the newly selected cell.

    In the selectionChanged event handler, you can check whether the current row is editable or not and update the isReadOnly property of that column accordingly.

    Regards,

    Ashwin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels