Home Forums WPF controls Xceed DataGrid for WPF Disabling sorting

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

    How do you make a DataGridControl “unsortable”? I don’t want anything to happen when you click on the headers

    Thanks

    Imported from legacy forums. Posted by nmosafi (had 9222 views)

    User (Old forums)
    Member
    Post count: 23064

    Unfortunatly, this is not possible in the current version… But we know that this is an important feature and it is top on our list for v1.1.

    You could try to hack a workaround by handling the PreviewMouseLeftButtonDown on ColumnManagerCell and setting e.Handled=true, but you would disable drag&drop reordering of the columns as well as drag&drop to the GroupByControl at the same time… 🙁

    Or, you could derive from ColumnManagerCell, override OnMouseLeftButtonDown/Up, paste our code for these methods and strip the code that triggers the sorting of a column (assuming you have the Blueprint edition or a bit of refl… err, creativity 😉

    Imported from legacy forums. Posted by Pascal (had 659 views)

    User (Old forums)
    Member
    Post count: 23064

    Pascal,

    Would you mind showing us how to attach to the PreviewMouseLeftButtonDown event on ColumnManagerCell.

    Imported from legacy forums. Posted by Patrick (had 740 views)

    User (Old forums)
    Member
    Post count: 23064

    <xcdg:DataGridControl xcdg:ColumnManagerCell.PreviewMouseLeftButtonDown=”HandlePreviewMouseButtonDown” />

    private void HandlePreviewMouseButtonDown( object sender, RoutedEventArgs e )
    {
    e.Handled = true;
    }

    Imported from legacy forums. Posted by Pascal (had 607 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    do you have an example to strip the code that triggers the sorting of a column?

    Thanks!!
    Criss

    Imported from legacy forums. Posted by Criss (had 461 views)

    Xceed Support
    Member
    Post count: 5658

    You can set the AllowSort property of the ColumnManagerRow to false to prevent columns from being sorted.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 341 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks Jenny,

    but I have derived from ColumnManagerCell to override the OnMouseLeftButtonDown/Up methods.
    Now I want use my ColumnManagerCell in a DataGrid, how can I made this?

    Imported from legacy forums. Posted by Criss (had 431 views)

    Xceed Support
    Member
    Post count: 5658

    You also need to derive from ColumnManagerRow and return your ColumnManagerCell in the CreateCell override.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 330 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Jenny,

    thanks for the help, I’ve also derived from ColumnManagerRow and I’ve overrided the CreateCell method.

    Now I have another problem: how can I use my ColumnManagerRow? I’ve try this:

    DataTemplate template = new DataTemplate();
    template.VisualTree = new FrameworkElementFactory(typeof(myColumnManagerRow));
    ctrlGrid.View.FixedHeaders.Add(template);

    Is it correct?

    Thanks
    Criss

    Imported from legacy forums. Posted by Criss (had 780 views)

    Xceed Support
    Member
    Post count: 5658

    Can you describe the nature of the problem you are experiencing with the code you posted? That will help us determine the nature of the problem.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 535 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Marc,

    I have a grid with many groups. Each group has a footer row (calculate server side) with the total for each column.
    I have a problem with the default column sorting because my footer rows became also reorded with the other rows…

    Imported from legacy forums. Posted by Criss (had 384 views)

    Xceed Support
    Member
    Post count: 5658

    I meant: What is the problem with this code?

    DataTemplate template = new DataTemplate();
    template.VisualTree = new FrameworkElementFactory(typeof(myColumnManagerRow));
    ctrlGrid.View.FixedHeaders.Add(template);

    It seems correct, but I’d like to know what are the problems you are encountering with it.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 523 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Marc,

    I have this problem:

    My override CreateCell method (present in myColumnManagerRow class) does not come called from the grid… this is the code:

    public class myColumnManagerCell : ColumnManagerCell
    {
    protected override void OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
    {

    }

    protected override void OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs e)
    {

    }
    }

    public class myColumnManagerRow : ColumnManagerRow
    {
    public myColumnManagerCell CreateCell(BoardColumnManagerCell columnManagerCell)
    {
    return new myColumnManagerCell();
    }
    }

    Imported from legacy forums. Posted by Criss (had 567 views)

    Xceed Support
    Member
    Post count: 5658

    you need to override the already existing virtual function that is defined on the Row class… It is named “protected abstract Cell CreateCell( Column column )”

    Your function would look like:

    protected override Cell CreateCell( Column column )
    {
    return new MyColumnManagerCell();
    }

    Imported from legacy forums. Posted by Marcus [Xceed] (had 584 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Marc,

    thank you very much, now it works correctly!!!!!

    Criss

    Imported from legacy forums. Posted by Criss (had 10676 views)

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