How to set the row style based on a column value?

Posted by: vkarumbaiah1 on 8 September 2017, 8:46 am EST

  • Posted 8 September 2017, 8:46 am EST

    Hi

    I am trying to set the appearance and behavior of a row based on the value in a column.



    I have a grid containing 3 columns.



    The 1st column is editable, the 2nd is not editable and the 3rd is hidden.



    Now, the value in the 3rd column is a boolean value and when the value in this column is False I want to do the following to the row that cell is in.



    1. Change the background color of the row where the value in the 3rd col is false.

    2. Lock the 1st column in that row so the user can not edit the data.

    3. Show a popup with a message when the user double clicks that row.



    Which events should I write the code in and what methods should use to read the value of a cell and set the row style and behavior? Im coding in VB.Net so I would be very grateful if any sample code is in the same. 



    I am using ver 1.0.8.0 of the grid.



    Any help is greatly appreciated

    Thanks



    Vikram Karumbaiah

  • Posted 8 September 2017, 8:46 am EST

    Vikram,



    You would need to loop through the data in column 3 after loading the data in the Spread. Check for a False value and programatically set the BackColor for that row and lock column 0 of that row. Then, client side you can write code to catch the ondoubleclick of the Spread. In the event, you can check if cell 0 of that row is locked. If it is, then display an alert.

  • Posted 8 September 2017, 8:46 am EST

    Do you have any sample code that I can refer to to see waht methods and events I can use?



    Ive just started using the grid and dont have much time to do a lot of reading.



    Thanks Scott

    Vikram

  • Posted 8 September 2017, 8:46 am EST

    Vikram,



    I do not have any samples. What problems are you having? You can use the GetValue method on the Spread to get the values from the Spread. Then in client side code you can catch the ondblclick for the Spread object and write code to check the event.srcIndex to get the TableCell in the Spread object that is being double clicked. With that information, you can find out if the 1st cell of that row is locked and throw your alert message.

  • Posted 8 September 2017, 8:46 am EST

    Hi scott

    I was unclear on how to use the getvalue method and whether this should be coded client side or in the grid events. I did get to do some reading and get familiar with the grid so I managed to answer my question.

    Thanks so much for your help

    Vikram

  • Posted 2 November 2018, 2:19 am EST

    We are on Spread.11…

    Is the above process still the only way to achieve that scenario…

    We have similar requirements… we have 3 cells on a row, that need to be a different color (each of them might be a different color from the cell) … based upon values in a recordset… at the time that the row /cell is being loaded.

    Do we have to wait until the entire spread-sheet is loaded to loop back through?

Need extra support?

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

Learn More

Forum Channels