I've got a WebGrid with sorting set to OnClient, but it doesn't work as expected. The values a strings and when clicking again for descending order the sort icon changes but the values are not sorted.
Are there any 'gotchas' that I should be aware to get this working?
I've got AutoGenerateColumns set to false and the columns are bound to custom object collection. Any ideas what might be wrong?
Hi Ivan,
thank you for your response and apologies for the delayed reply.
In order to reproduce the problem use the HTML markup I posted earlier and the important bit is in the MapColumnValue(Container) used in the templated columns. As you will see from the code bellow the cell value is explicitly set (different from the uderlying bound value), but the sorting seems to use the underlying databound column.
My question is what's the best way to handle this situation?
{
LegalEntityQV legalEntity = (LegalEntityQV)cellItem.DataItem;
value = (legalEntity.StatusDetails.EntityStatus == EntityStates.SignedOff) ? "Verified" : "Unverified";
case "VerificationDate":
cellItem.Cell.Column.DataType = "System.DateTime"; // the data type is important for the excel export
break;
cellItem.Cell.Column.DataType = "System.Int16"; // the data type is important for the excel export
}
Hello,
I am trying to reproduce the problem, unfortunately to no avail... I use my data source (declarative binding to Northwind database) and your DisplayLayout tag and work normally. Could you please send your code-behind or sample project. There have meaning to what type data source you use.
Thanks.
Here's all the markup, I only set the datasource and bind it in the code behind:
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" DataKeyField="Id" OnInitializeDataSource="UltraWebGrid1_InitializeDataSource" Browser="Xml" > <Bands> <igtbl:UltraGridBand AllowColSizing="Free" DataKeyField="Id" Key="LegalEntityList"> <Columns> <igtbl:UltraGridColumn BaseColumnName="Id" DataType="System.Int32" Hidden="True" IsBound="True" Key="Id" Width="30px"> <Header Caption="Id"> </Header> </igtbl:UltraGridColumn> <igtbl:TemplatedColumn BaseColumnName="LegalEntityName" IsBound="True" Key="LegalEntityName" Width="220px"> <CellTemplate> <asp:LinkButton runat="server" ID="lbLegalEntity" Text='<%# Eval("LegalEntityName") %>' CommandName="LegalEntityDetail" CommandArgument="<%# Container.Cell.Row.Index %>" OnCommand="OnButtonCommand" /> </CellTemplate> <HeaderStyle Cursor="Hand" Font-Bold="True" /> <Header Caption="Legal Entity Name" TitleMode="Always"> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:TemplatedColumn> <igtbl:UltraGridColumn BaseColumnName="ConnectionName" IsBound="True" Key="ConnectionName" Width="190px"> <HeaderStyle Cursor="Hand" Font-Bold="True" /> <Header Caption="Connection Name"> <RowLayoutColumnInfo OriginX="2" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="2" /> </Footer> </igtbl:UltraGridColumn> <igtbl:TemplatedColumn BaseColumnName="StatusDetails" Key="VerificationStatus" Width="80px"> <CellTemplate> <%# MapColumnValue(Container) %> </CellTemplate> <HeaderStyle Cursor="Hand" Font-Bold="True" Wrap="True" /> <Header Caption="Verification Status"> <RowLayoutColumnInfo OriginX="3" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="3" /> </Footer> </igtbl:TemplatedColumn> <igtbl:TemplatedColumn BaseColumnName="StatusDetails" Key="VerificationDate" Width="80px"> <CellTemplate> <asp:Label ID="lblVerificationDate" Text="<%# MapColumnValue(Container) %>" runat="server" /> </CellTemplate> <HeaderStyle Cursor="Hand" Font-Bold="True" Wrap="True" /> <Header Caption="Verification Date"> <RowLayoutColumnInfo OriginX="4" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="4" /> </Footer> </igtbl:TemplatedColumn> <igtbl:TemplatedColumn BaseColumnName="StatusDetails" DataType="System.Int16" Key="LE" SortIndicator="Disabled" Width="40px"> <CellTemplate> <asp:Label ID="lblLE" Text="<%# MapColumnValue(Container) %>" runat="server" /> </CellTemplate> <HeaderStyle Cursor="Default" Font-Bold="True" HorizontalAlign="Center" /> <CellStyle HorizontalAlign="Center"> </CellStyle> <Header Caption="LE"> <RowLayoutColumnInfo OriginX="5" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="5" /> </Footer> </igtbl:TemplatedColumn> <igtbl:TemplatedColumn BaseColumnName="FacilityListStatusCode" DataType="System.Int16" Key="FacList" SortIndicator="Disabled" Width="40px"> <CellTemplate> <asp:Label ID="lblFacList" Text="<%# MapColumnValue(Container) %>" runat="server" /> </CellTemplate> <HeaderStyle Cursor="Default" Font-Bold="True" HorizontalAlign="Center" Wrap="True" /> <CellStyle HorizontalAlign="Center"> </CellStyle> <Header Caption="Fac List"> <RowLayoutColumnInfo OriginX="6" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="6" /> </Footer> </igtbl:TemplatedColumn> <igtbl:UltraGridColumn BaseColumnName="FacilityOutstandingCount" DataType="System.Int16" Key="FacDetails" SortIndicator="Disabled" Width="48px"> <HeaderStyle Cursor="Default" Font-Bold="True" HorizontalAlign="Center" Wrap="True" /> <CellStyle HorizontalAlign="Center"> </CellStyle> <Header Caption="Fac Details"> <RowLayoutColumnInfo OriginX="7" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="7" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="SecurityOutstandingCount" DataType="System.Int16" Key="SecDetails" SortIndicator="Disabled" Width="48px"> <HeaderStyle Cursor="Default" Font-Bold="True" HorizontalAlign="Center" Wrap="True" /> <CellStyle HorizontalAlign="Center"> </CellStyle> <Header Caption="Sec Details"> <RowLayoutColumnInfo OriginX="8" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="8" /> </Footer> </igtbl:UltraGridColumn> </Columns> <AddNewRow View="NotSet" Visible="NotSet" /> <SelectedRowStyle BackColor="MenuHighlight" /> </igtbl:UltraGridBand> </Bands> <DisplayLayout Name="ctl32xUltraWebGrid1" RowHeightDefault="18px" Version="3.00" RowSizingDefault="Free" AllowColumnMovingDefault="OnServer" AllowSortingDefault="OnClient" HeaderClickActionDefault="SortMulti" LoadOnDemand="Xml" RowSelectorsDefault="No" StationaryMargins="Header" TableLayout="Fixed" AllowColSizingDefault="Free" AutoGenerateColumns="False" NoDataMessage="No Legal Entities Found" > <FrameStyle BorderColor="InactiveCaption" BorderStyle="Solid" BackColor="Window" BorderWidth="1px" Font-Bold="False"> </FrameStyle> <FooterStyleDefault BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" /> </FooterStyleDefault> <HeaderStyleDefault BackColor="White" BorderStyle="Outset" Cursor="Hand" HorizontalAlign="Left" Font-Bold="True" Font-Names="Arial,Sans-Serif" Font-Size="0.95em"> </HeaderStyleDefault> <RowStyleDefault BackColor="Window" BorderColor="Gainsboro" BorderStyle="Solid" BorderWidth="1px" Wrap="True" > <Padding Left="2px" /> <BorderDetails ColorLeft="Window" ColorTop="Window" /> </RowStyleDefault> <ActivationObject BorderColor="" BorderWidth="" /> <FilterOptionsDefault FilterUIType="HeaderIcons"> <FilterDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Size="11px" Width="200px" Height="300px"> <Padding Left="2px" /> </FilterDropDownStyle> <FilterHighlightRowStyle BackColor="#151C55" ForeColor="White"> </FilterHighlightRowStyle> <FilterOperandDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Size="11px"> <Padding Left="2px" /> </FilterOperandDropDownStyle> </FilterOptionsDefault> <RowAlternateStyleDefault BackColor="#EBEBD6"> </RowAlternateStyleDefault> <Pager MinimumPagesForDisplay="2"> <PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" /> </PagerStyle> </Pager> <GroupByRowStyleDefault BackColor="Control" BorderColor="Window"> </GroupByRowStyleDefault> <GroupByBox> <BoxStyle BackColor="ActiveBorder" BorderColor="Window"> </BoxStyle> </GroupByBox> <AddNewBox> <BoxStyle BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid" BorderWidth="1px"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" /> </BoxStyle> </AddNewBox> <FixedHeaderStyleDefault Cursor="Hand" Font-Bold="False"> </FixedHeaderStyleDefault> </DisplayLayout> </igtbl:ultrawebgrid>
Could you please send a little bit more information about the WebGrid declaration. ASPX declaration, code-behind or sample project - anything that can get us started is welcome. When you bind to custom object collection and doesn`t declare columns and the property AutoGenerateColumns ="false" data is not be displayed.