简体   繁体   中英

DevExpress grids how to turn off sorting of columns

strong text I have grids showing to user and want to not allow sorting per column because I have added in totals where do I do this?

          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
                xmlns:devx="http://schemas.devexpress.com/winfx/2008/xaml/grid">
//* * * * * * * *

•Your post does not have much context to explain the code sections; please explain your scenario more clearly.

    <Grid x:Name="LayoutRoot" >
        <Border BorderThickness="2" BorderBrush="AliceBlue" Margin="10" >
            <StackPanel  >
                <Grid Background="AliceBlue" Height="30" >
                    <TextBlock VerticalAlignment="Center" FontWeight="Bold" Margin="5" Text="Upload File">
                    </TextBlock>
                </Grid>
                <Grid>
//* * * * * * * *

                    <Grid.RowDefinitions>
                        <RowDefinition ></RowDefinition>
                        <RowDefinition Height="800"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="5">
                        <Button Content="Upload File" Margin="0" Width="70" Height="35" Command="{Binding CmdUploadFile}" IsEnabled="{Binding IsEnableUploadFile, Mode=TwoWay}" ></Button>
                        <Button Content="Export" Margin="2,0,0,0" Width="70" x:Name="btnExport" Click="btnExport_Click"></Button>
                    </StackPanel>
//* * * * * * * *

                    <devx:GridControl 
                        Grid.Row="1"  x:Name="dgTest" 
                        ShowLoadingPanel="{Binding Path=IsLoading, Mode=TwoWay}"
                        ItemsSource="{Binding Path=LstData, Mode=TwoWay}" 
                        AutoPopulateColumns="False"
                        HorizontalAlignment="Stretch" 
                        VerticalAlignment="Stretch" 
                        AllowColumnMRUFilterList="False" 
                        IsFilterEnabled="False">
//* * * * * * * *


                        <devx:GridControl.Columns>
                            <devx:GridColumn Header="Fac ID"           FieldName= "FacID"          ReadOnly="True" Width="100" ></devx:GridColumn>
                            <devx:GridColumn Header="Patient ID"       FieldName= "PatID"          ReadOnly="True" Width="100" ></devx:GridColumn>
                            <devx:GridColumn Header="Patient"          FieldName= "Patient"        ReadOnly="True" Width="200" ></devx:GridColumn>
                            <devx:GridColumn Header="Price Cd"         FieldName= "PriceCd"        ReadOnly="True" Width="100" ></devx:GridColumn>
                            <devx:GridColumn Header="Invoice Group"    FieldName= "InvoiceGrp"     ReadOnly="True" Width="100" ></devx:GridColumn>
                                                  </devx:GridControl.Columns>
//* * * * * * * *

                        <devx:GridControl.View>
                            <devx:TableView></devx:TableView>
                        </devx:GridControl.View>
                    </devx:GridControl>
//* * * * * * * *

                       </Grid>
                           </StackPanel>
                                  </Border>
                                               </Grid>

//* * * * * * * *


                        </UserControl>

尝试这个

<devx:TableView AllowSorting="False"></devx:TableView>

You should go through the Sorting section of the WPF XtraGrid

To remove sorting against a column the following can be done.

  • Set the column's GridColumn.SortOrder property to ColumnSortOrder.None.

  • Remove the item that refers to the required column from the ColumnView.SortInfo collection.

  • Call the ColumnView.ClearSorting method. This will remove the sort settings for all columns (except for grouping columns).

    gridView1.Columns["Country"].SortOrder = DevExpress.Data.ColumnSortOrder.None;

To prevent data sorting/grouping for specific columns use the OptionsColumn.AllowSort property.

Ref: Sortable and Non-Sortable Columns

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM