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
40
Unbound column with dynamically bound EditorComponents
posted

OK, so I've searched for several days now, and am ready to rip my hair out.

First, what I'm trying to accomplish. We have a system by which a client is able to define various "criteria" for a ranking system. Each question has a backing field associated with it as well as an underlying data type. Using that info, we create a data table with the data fields as columns of the specified data type. So we have a grid bound to the "Questions" table, with the only displayed column being the question itself. We then add an unbound "Answer" column of type Object (since it needs to support multiple data types).

Now, what I'm trying to do is set the EditorComponent of the Answer column for each Question row to a corresponding editing control that is bound to this new table we create based on the DataFields/FieldTypes of each row. Each component (UltraCheckEditor, UltraDateTimeEditor, and UltraNumericEditor) has a Binding programmatically added to it, binding it to the new "DataMapping" table (with the field to bind to pulled from the Questions.DataField column).

Not sure if I am clear in my requirements, but I created a test project that shows exactly what I'm trying to do. The top grid shows the "Questions" table, and the bottom grid shows the new DataTable that was generated via the DataField/FieldType from the "Questions" table (bound via a BindingSource). The problem I'm running into is that while I'm able to actually create the data bound editor component for each row, the updates are not propogating to the newly derived table row.

Now I've tried binding directly to the "DataMapping", directly to the only row in the "DataMapping" table (via DataRowView), setting up an UltraControlContainerEditor for each row (with Editing and Rendering controls set and bound). Updates to the editing controls just do not want to propogate to the underlying data source (being the "DataMapping" table).

UltraWinGrid file version is 12.1.20121.2054.

UltraGridEditorExample.zip
Parents
No Data
Reply
  • 69832
    Verified Answer
    Offline posted

    In short, the reason that the data isn't being persisted to the DataMapping table is that the control instances that are assigned to the EditorComponent property are only used to provide embeddable editors to the grid - the actual control instances are not active in the user interface, and the values of the control's properties are not changed set when you edit a cell in the grid. When you use one of these controls as an editor provider, you are basically telling the grid cell, "use an editor that has the same functionality as this control, and when the editor's value changes, write that to the cell's value".

    If I am understanding this correctly, there are two different data source at play here (one for the questions and one for the answers), and the UltraGrid is not designed to handle two data sources simultaneously. One possible solution would be to handle the relevant grid events and manually write the data back to this DataMapping table. Another might be to use a two-band grid where the root band represents the person answering the question, with the second band consisting of a child row for each question. If either of these approaches sounds feasible, and you have any questions about how to implement it, repost and we'll try to help.

Children