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
1105
XamGrid ComboboxColumn disable based on data from another item
posted

Hi,

I have a XamGrid which is bind to a list of objects.

The grid contain ComboboxColumn.

I would like to make the combobox disabled (or even hidden if possible) for certain rows, based on a boolean value which is part of the object.

How could I do that in XamGrid?

<ig:ComboBoxColumn Key="AggregationMethod" HeaderText="Aggregation Method" AllowEditingValidation="True" EditorDisplayBehavior="Always" >
<ig:ComboBoxColumn.CellStyle>
<Style TargetType="ig:CellControl">
<Setter Property="Margin" Value="1"></Setter>
<Setter Property="Padding" Value="0"></Setter>
</Style>
</ig:ComboBoxColumn.CellStyle>
<ig:ComboBoxColumn.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource aggrConverter}}" />
</DataTemplate>
</ig:ComboBoxColumn.ItemTemplate>

</ig:ComboBoxColumn>

The data class contain:

Enum AggregationMethod

bool AllowAggregation

the combobox should be disabled when the AllowAggregation = false

  • 2700
    Offline posted
    Hello Eli,

     

    Thank you for the provided code-snippet.

     

    I have been looking into your requirement and created a small sample with a XamGrid to demonstrate how it can be achieved.

     

    By referring to the ComboBoxColumn API here, I determined that there is no public property exposed to set whether it is enabled or editable. So my suggestion is to use a Template Column instead and define a XamComboEditor (or a simple WPF ComboBox) for its Item and Editor Templates:

     

    <ig:TemplateColumn Key="UnitCategory"
                                       HeaderText="Units">
                        <ig:TemplateColumn.ItemTemplate>
                            <DataTemplate>
                                <igWPF:XamComboEditor Width="100"
                                          ItemsSource="{Binding Source={StaticResource vm}, Path=UnitCategories}"
                                          SelectedItem="{Binding UnitCategory}"
                                          IsEnabled="{Binding boolProp}"/>
                            </DataTemplate>
                        </ig:TemplateColumn.ItemTemplate>
                        <ig:TemplateColumn.EditorTemplate>
                            <DataTemplate>
                                <igWPF:XamComboEditor Width="100"
                                          ItemsSource="{Binding Source={StaticResource vm}, Path=UnitCategories}"
                                          SelectedItem="{Binding UnitCategory}"
                                          IsEnabled="{Binding boolProp}" />
                            </DataTemplate>
                        </ig:TemplateColumn.EditorTemplate>
                    </ig:TemplateColumn>

     

    Both combo editors expose an IsEnabled property, which can be bound to a Boolean property of your data model.

     

    I would also like to mention that we recommend that you use the XamDataGrid control instead of the XamGrid control. The XamGrid is being planned for retirement over the next few years and will not receive any new features.

     

    Attached you will find the sample for your reference. Please, test it on your side and if you require any further assistance on the matter, please let me know.

     

    Sincerely,
    Bozhidara Pachilova
    Associate Software Developer