Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
9364
Display data in a different utnit of measure
posted

I have grid where each cell represents some quantity of different widgets. I would like the user to be able to press on button and switch from the quantity of the widget to its value. So, for example, widget1 is worth $5 a piece and widget2 is $6 a piece

Qty based display 

widget1       1       2      3

widget2        5      10   15

Corresponding $ based display

widget1        $5        $10      $15

widget2        $30      $60      $90

This $-based grid is not editable since it is derived from the qty based information. But the qty-based grid is editable and how the information would be held in the datatable. 

Since this $-based information is not editable, I am hoping I do not have to generate another datatable to hold these derived numbers. What are my options?

Thanks!

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    I'm a little fuzzy on what the actual data looks like here. Does the data contain the quantities or the prices? Or both? Is the value just a straight multiplication of quantity times some constant? 

    It seems like the thing to do here is use unbound columns and hide the "real" column. Let's say, for example, that the data source here contains quantities and the $ values are determined by some calculation. I would bind the grid to the quantities and hide the actual columns, then create an equal number of unbound column in the grid. Use the InitializeRow event of the grid to copy the value of the "real" column into the unbound column. You can base whether or not to copy the actual value or the $ value on a flag.

    To handle updates, you would handle the BeforeRowUpdate event and reverse this process, copying the unbound column value into the "real" column.

    the only other issue is what to do to get the grid to refresh when you change your flag. This is easy - you just call grid.Rows.Refresh(FireInitializeRow).

Children
No Data