Filtering
<sq8:GridDateTimeColumn FilterControlWidth="120px" DataField="date" HeaderText="ShippedDate" SortExpression="date" UniqueName="date" PickerType="DatePicker" DataFormatString="{0:D}" EnableRangeFiltering="true"> <HeaderStyle Width="160px" /> </sq8:GridDateTimeColumn>
Column Reordering with Drag-and-Drop
You can reorder columns using drag-and-drop. Use the following example to enable column reordering.
<ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" ColumnsReorderMethod="Reorder"> <Animation AllowColumnReorderAnimation="True" AllowColumnRevertAnimation="True"></Animation></ClientSettings>
Column Binding
Explicitly-created columns.
<sq:Grid ID="Grid1" runat="server"> ... <MasterTableView DataSourceID="ProductsDataSource" TableLayout="Auto"> ... <Columns> <sq:GridBoundColumn DataField="ProductID" DataType="System.Int32" HeaderText="Product ID" SortExpression="ProductID" UniqueName="ProductID"> </sq:GridBoundColumn> <sq:GridBoundColumn DataField="ProductName" HeaderText="Product Name" SortExpression="ProductName" UniqueName="ProductName"> </sq:GridBoundColumn> <sq:GridBoundColumn DataField="UnitPrice" DataType="System.Decimal" HeaderText="Unit Price" SortExpression="UnitPrice" UniqueName="UnitPrice"> </sq:GridBoundColumn> </Columns> ... </MasterTableView>
Resizing Columns
<sq:Grid runat="server" ID="Grid1" GridLines="None" CellSpacing="0"DataSourceID="DataSource1"> <ClientSettings> <Resizing AllowColumnResize="True" AllowRowResize="false"ResizeGridOnColumnResize="false" ClipCellContentOnResize="true" EnableRealTimeResize="false" AllowResizeToFit="true"/> </ClientSettings> ... </sq:Grid>
Exporting
This is a configuration example.
<CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToCsvButton-"true" ShowExportToPdfButton="true"/>
Basic Paging
<sq:Grid runat="server" ID="Grid2" DataSourceID="Address_DS" GridLines="None" Width="95%" CellSpacing="0" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowSorting="True" ShowStatusBar="True" PageSize="5" AllowPaging="True" AllowCustomPaging="True"> </sq:Grid>
Calculated Column
You can sort, group, and filter columns the same way you would GridBoundColumn. You specify the columns used in the calculation in the DataFields property. The actual calculation is defined in the expression property.
<Columns> .. <sq:GridCalculatedColumn HeaderText="TotalPrice" UniqueName="TotalPrice" DataType="System.Double" DataFields="UnitPrice, UnitsInStock" Expression="{0}*{1}" FooterText="Total : "Aggregate="Sum" /> .. </Columns>
This is an example of Aggregate and CalculatedColumn functions in a grid.
<%@ Control %> <sq:Grid runat="server" ID="Grid1" CellSpacing="0" GridLines="None" DataSourceID="DataSource1" AutoGenerateEditColumn="True" AutoGenerateDeleteColumn="True" AutoGenerateColumns="False" ShowFooter="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"> <MasterTableView DataKeyNames="fldId" DataSourceID="DataSource1"> <RowIndicatorColumn Visible="True"></RowIndicatorColumn> <ExpandCollapseColumn Visible="True"></ExpandCollapseColumn> <Columns> <sq:GridNumericColumn DecimalDigits="0" DataField="Field1" Aggregate="Max" HeaderText="Field1" SortExpression="Field1" UniqueName="Field1" DataType="System.Int32"></sq:GridNumericColumn> <sq:GridNumericColumn DecimalDigits="2" DataField="Field2" Aggregate="Sum" HeaderText="Field2" SortExpression="Field2" UniqueName="Field2" DataType="System.Double"></sq:GridNumericColumn> <sq:GridCalculatedColumn Aggregate="Sum" DataFields="Field1,Field2" Expression="{0}*{1}" FooterText="Total : " HeaderText="Total Price" UniqueName="TotalPrice" DataType="System.Double"></sq:GridCalculatedColumn> </Columns> </MasterTableView> </sq:Grid>
Grid Hierarchy
<sq:Grid runat="server" ID="Grid1" CellSpacing="0" GridLines="None" DataSourceID="DataSource1" AutoGenerateEditColumn="True" AutoGenerateDeleteColumn="True" AllowSorting="True" AllowFilteringByColumn="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"> <MasterTableView DataKeyNames="fldId" DataSourceID="DataSource1" AutoGenerateColumns="False"> <RowIndicatorColumn Visible="True"> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn Visible="True"> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <DetailTables> <sq:GridTableView DataKeyNames="fldId" DataSourceID="DataSource2" Width="100%" runat="server" AutoGenerateColumns="False"> <ParentTableRelation> <sq:GridRelationFields DetailKeyField="Key" MasterKeyField="fldId"> </sq:GridRelationFields> </ParentTableRelation> <Columns> <sq:GridNumericColumn DecimalDigits="0" DataField="fldId" ReadOnly="True" HeaderText="fldId" SortExpression="fldId" UniqueName="fldId" DataType="System.Int32"></sq:GridNumericColumn> <sq:GridNumericColumn DecimalDigits="0" DataField="Key" ReadOnly="True" HeaderText="Key" SortExpression="Key" UniqueName="Key" DataType="System.Int32"></sq:GridNumericColumn> <sq:GridBoundColumn DataField="Field1" HeaderText="Field1" SortExpression="Field1" UniqueName="Field1"></sq:GridBoundColumn> </Columns> </sq:GridTableView> </DetailTables> <Columns> <sq:GridNumericColumn DecimalDigits="0" DataField="fldId" ReadOnly="True" HeaderText="fldId" SortExpression="fldId" UniqueName="fldId" DataType="System.Int32"></sq:GridNumericColumn> <sq:GridBoundColumn DataField="Field1" HeaderText="Field1" SortExpression="Field1" UniqueName="Field1"></sq:GridBoundColumn> <sq:GridBoundColumn DataField="Field2" HeaderText="Field2" SortExpression="Field2" UniqueName="Field2"></sq:GridBoundColumn> </Columns> </MasterTableView> </sq:Grid> <sq:DataSource runat="server" ID="DataSource2" QueryName="UACT1" Where="Key == @Key"><WhereParameters> <asp:SessionParameter SessionField="Key" Name="Key" Type="Int32"></asp:SessionParameter> </WhereParameters> </sq:DataSource> <sq:BoundControl runat="server" TargetControlID="Grid1"></sq:BoundControl> <sq:DataSource runat="server" ID="DataSource1" QueryName="Form1"></sq:DataSource>