Home Forums WPF controls Xceed DataGrid for WPF Checkbox in GroupHeaderFooterItem

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25691 |

    hi

    Is there an example of a check box in the group header.

    I have added one to the group header and added a clicked event that loops through the items in the group and checks all check boxes in a particular column.

    I have added some recursion to handle groups within groups.

    BUT what i am having troubles with is accessing the header checkboxes in the the sub group headers and checking that checkbox, when the parent group check box is Clicked.

    Here is a what i am doing:

    <UserControl.Resources>
    <DataTemplate DataType=”{x:Type xcdg:Group}”>
    <StackPanel Orientation=”Horizontal”>
    <TextBlock Text=”The “/>
    <TextBlock Text=”{Binding Value}”/>
    <TextBlock Text=” group contains “/>
    <TextBlock Text=”{Binding Items.Count}”/>
    <TextBlock Text=” items.”/>
    <TextBlock Text=” Include All “/><CheckBox Name=”GroupInclude” Click=”CheckBox_Click” />
    </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key=”includedGroupValueTemplate”>
    <TextBlock x:Name=”tbIncluded”
    Text=”Yes” />
    <DataTemplate.Triggers>
    <DataTrigger Binding=”{Binding}”
    Value=”False”>
    <Setter TargetName=”tbIncluded”
    Property=”Text”
    Value=”No”/>
    </DataTrigger>
    </DataTemplate.Triggers>
    </DataTemplate>

    </UserControl.Resources>

    <xcdg:DataGridControl Grid.Row=”1″ Name=”GridControl” Visibility=”Visible”>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”Included” Title=”Included”
    Width=”80″
    />
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>

    private void CheckBox_Click(object sender, RoutedEventArgs e)
    {
    bool result = (bool)((System.Windows.Controls.CheckBox)sender).IsChecked;

    GroupHeaderFooterItem header =
    (GroupHeaderFooterItem)this.GridControl.GetItemFromContainer(sender as DependencyObject);

    if( !header.Equals( GroupHeaderFooterItem.Empty ) )
    {
    CollectionViewGroup group = this.GridControl.GetParentGroupFromItem(header);
    if( group != null )
    {
    for (int x = 0; x < group.ItemCount; x++)
    {
    object item = group.Items[x];
    if (item is CollectionViewGroup)
    {
    this.SelectRecurse((CollectionViewGroup)item, result);
    }
    else
    {
    ((System.Data.DataRow)item).BeginEdit();
    ((System.Data.DataRow)item)[“Included”] = result;
    ((System.Data.DataRow)item).EndEdit();
    }
    }
    }
    }
    }

    private void SelectRecurse(CollectionViewGroup group, bool result)
    {
    //GroupHeaderFooterItem header = (GroupHeaderFooterItem)GridControl.GetItemFromContainer();
    for (int x = 0; x < group.ItemCount; x++)
    {
    object item = group.Items[x];
    if (item is CollectionViewGroup)
    {
    this.SelectRecurse((CollectionViewGroup)item, result);
    }
    else
    {
    ((System.Data.DataRow)item).BeginEdit();
    ((System.Data.DataRow)item)[“Included”] = result;
    ((System.Data.DataRow)item).EndEdit();
    }
    }
    }

    Imported from legacy forums. Posted by Alan (had 2363 views)

    User (Old forums)
    Member
    Post count: 23064

    What exactly the problem are you having?

    Imported from legacy forums. Posted by nat (had 356 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi

    The problem i am having is accessing the checkbox in a sub group header.

    i currently have a checkbox in a the group header that when checked will check boxes in a certain column of items in that group. It also handles groups within groups, but i cannot access the check box in the sub group header to automaticlly check it.

    Any suggestions?

    Thanks very much

    Alan

    Imported from legacy forums. Posted by Alan (had 3620 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.