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
235
UltraGrid: Data binding to dynamic cell
posted

Hi,

I am trying to figure out a way to do the follow:

I have an UltraGrid with 1 hidden primary key column and  5 visible data columns.

Column 1 and 2 are drop down lists.
Column 3 is a dynamic cell.
Column 4 is a text field
Column 5 is a drop down list. 

I have an ultra data source, a DataSet, and DataTable.  The DataTable matches the ultraDataSouce:
string, string, object, double, string. I can data bind the Columns 1, 2, 4, and 5. But column 3 is the tricky one. 

When the user makes a selection on column 2, the cellListSelected event is fired, and its event handler should analyze the selection, and make column 3 a text field, edit field with an edit button, default text with an edit field and edit button, or a drop down list for other selections.

My question is, how does data binding work with such a situation? Is it even possible?

 

Thanks

Parents
  • 469350
    Offline posted

    Hi,

    I'm not quite sure what you mean by "dynamic cell", but it sounds like you want the cell to handle different data types.

    If that's the case, then it sounds like you are on the right track using object as the data type for that column. 

    Beyond that, it seems like you will need to assign a different Editor/EditorComponent to the cell in column 3 based on the value in Column 2. You can't use just the CellListSelect event for this, since this event will only fire when the user selects an item from the list. This will not account for the case when the grid displays the first time, for example.

    So I would recommend using the InitializeRow event, and maybe also AfterCellUpdate.

    In InitializeRow, you examine the value of Column 2 and then assign an Editor or EditorComponent to the cell in Column 3. For just a normal text field, you would use an UltraTextEditor. For a text field with a button, you would use a different UltraTextEditor control that has an EditorButton added to it's ButtonsRight collection. For a dropdown list, you have to use UltraComboEditor - or just reset the editor on the cell and use a ValueList.

     

Reply Children