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
55
Provide different ComboBoxItemsProvider per Row
posted

Hi there,

I have a XamDataGrid that is bound to a table.

Then on each row I want to provide a different display value for an Int field. Thing is, there are many thousands of values and we actually only want to display the current value. Previously we did this in WinForms with the ValueList and bound a different ValueList to each UltraGridRow.

Now we are converting to WPF and using XamDataGrid there might be a better way to do this - maybe using a converter?

Currently this is the code I have, my problem is that the ComboBoxItemsProvider, although generated dynamically with one value, only has the value of the last record. Of course I can make a work around to this by generating a List of all the items when the page is rendered, then bind all to that list.

Just wonder if;

a) Is there a way to have a different data source behind per Record for a single field?

b) Would I be better in this instance to use a Converter function to return the display value?

As an aside, when the user clicks on this field, they cannot edit it In-Line, a new editor starts.

Thanks in advance,

Steve

private void uxListView_InitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e)

{

DataRecord dr = e.Record as DataRecord;if (dr != null)

{

foreach (Cell cell in dr.Cells)

{

if (cell.Field.Name.IndexOf("_DES_") > 0)

{

// Get the Description Text for this Language/Theme

String des_DescId = cell.Value.ToString();

String descriptionText = _baseDataAccess.GetDES(des_DescId, "EN");

// Store the Description Id for later use?

cell.Field.Tag = des_DescId;

// Create the datasource for the Combo Box

LookUpItem item = new LookUpItem { ID = des_DescId, DisplayName = descriptionText };

ComboBoxItemsProvider lookUpItems = new ComboBoxItemsProvider();

lookUpItems.DisplayMemberPath = "DisplayName";lookUpItems.ValuePath = "ID";

lookUpItems.Items.Add(item);

// Use the setter to set the datasource

// Now this is where we really want to have a unique ValueList

Setter setter = new Setter();setter.Property = XamComboEditor.ItemsProviderProperty;

setter.Value = lookUpItems;

// Add the setter to the style and assign to this field

Style style = new Style(typeof(XamComboEditor));

style.Setters.Add(setter);

cell.Field.Settings.EditorStyle = style;

}

 

}

}

}

Parents
  • 55
    posted

    Ok. Since I don't need to edit inline have decided to go with a Converter.

    Converter looks fine, is bound when the grid is, I can step in to it and each values is returned fine. However...in the physical display on the UI. The text is empty.

    Any clues?

Reply Children
No Data