Have an updatable XamDataGrid, and users want a context-sensitive combo box drop-down.
(hope the image is readable)
Anyway, they want the values presented in the combo drop-down to be determined by other values in the row (company code, location, etc)
The dropdown currently shows all possible values, without consideration of context. It would be really nice to show only relevant values in the dropdown
-Bruce
Hello Bruce,
Thank you for posting to Infragistics Community!
I have been looking into your question and my suggestion is to setup your combo field as a ComboBoxField, or alternatively as a TmeplateField, so you can take advantage of the possible bindings. Attached you will find a sample demonstrating a possible solution with a TemplateField.
To provide a specific set of items depending on one or more of the Data Item’s properties, you could use a Converter. The sample shows passing a single property of the DataItem object as the converter value, however, the entire DataItem could also be passed and cast to its original model, so that more complex conditions are fulfilled.
Please, test the sample on your side and let me know if it helps. Please, note that you may need to further adapt this approach for the case when the meaningful properties are edited and do not meet theset of expected values/criteria.
Best regards,Bozhidara PachilovaAssociate Software Developer
8306.XDGDependantCombo.zip
The situation I'm working with is selecting payscale agreements for a given Location and date range. Employees in San Francisco are going to have different pay rates than employees in a small rural town. Most likely to have different ranges based on employee job position within a location.
This is getting close to what I need to do, still looking for...
1) I will need to look at multiple fields in the row, not just the 'State' value. I tried to use '.DataContext.DataItem" instead of ".DataContext.DataItem.State", and it caused an exception. Not sure what I need to put in to send entire row.
2) In the grid, some records will have a 'City' value already. Current value is 'lost' with this approach. I'm thinking that doing this at databind might help avoid this. Or maybe get existing value and set dropdown current value.
3) It may be possible to alter one of the fields that goes into determining the 'City' list... in this example, it would be as if someone changed the state value. I would need to be able to repopulate the dropdown if one of the inputs changes.
Regards
Bruce
Thank you for clarifying your requirements.
To address the first point, I have modified the previous sample to bind to the entire DataItem object. I did reproduce the exception, which was caused by the binding having a Two-way mode. This is not allowed for a read-only object. Omitting this mode fixes it.
Secondly, I determined that the binding of the EditTemplate’s combo editor to the SelectedItem property was not working as expected. The Value property needs to be bound and the binding would function properly. Additionally, this would work for initially binding the "City" values, in case they are set in the data source.
Regarding your third point, I am wondering if you had the chance to manually test the sample as this is already achieved. Please, test it by modifying any of the state values to “California”/”Florida”/”New Jersey”.
Below you can find attached the modified version of the previous sample. It should fulfil the listed requirements now. Please, test it on your side and let me know how it behaves.
Best regards,Bozhidara Pachilova
0042.XDGDependantCombo2.zip