WebGridSordi

6 replies. Last post: August 9, 2012 10:34 PM by Hans Kristian
Tags :
armore1972Member

Hi we have a Grid with a column (WebCombo) that contain this items ( product code)

'0090 010 05 5'

'0966 010 04 4'

'7999 020 05 5'

...

if we try to sorting this column, the sort doesn't work, in attach file there are an example

the correct sorting is

06240000....

071566 05...

071566 21...

07201621....

any ones can suggest me how to sorting this column?

Thanks


<ISWebGrid:WebGrid ID="WebGrid1" runat="server" UseDefaultStyle="True"
Width="100%" OnInitializeDataSource="WebGrid1_InitializeDataSource" OnAddRow="WebGrid1_AddRow"
OnInitializeLayout="WebGrid1_InitializeLayout" OnUpdateRow="WebGrid1_UpdateRow"
OnDeleteRow="WebGrid1_DeleteRow" DataCacheStorage="Session" DefaultStyleMode="Elegant"
OnInitializeRow="WebGrid1_InitializeRow"
OnInitializePostBack="WebGrid1_InitializePostBack" Style="margin-top: 0px; z-index: 90;" AllowAutoDataCaching="False">
<LayoutSettings AllowAddNew="Yes" AllowDelete="Yes" AllowEdit="Yes" AllowSorting="Yes" AutoHeight="true"
ResetNewRowValuesOnError="False" GridLines="Vertical" ColumnFooters="Yes" InProgressUIBehavior="ChangeCursorToHourGlass"
AllowExport="No" VerboseEditingInformation="True" AllowDefaultStyleMerging="True"
ColumnSetHeaders="Default" FilterBarVisible="False" AutoFitColumns="True" DisplayDetailsOnUnhandledError="true"
SelectFirstCellOnAdd="True" NewRowLostFocusAction="AlwaysPrompt" AllowMultipleSelection="Default"
>
<%--AllowSelectColumns="Yes" ShowColumnAction="True" >--%>
<ClientSideEvents OnBeforeAdd="WebGrid1_OnBeforeAdd" OnBeforeUpdate="WebGrid1_OnBeforeUpdate" OnBeforeDelete="WebGrid1_OnBeforeDelete" OnAfterAdd="WebGrid1_OnAfterAdd" OnAfterUpdate="WebGrid1_OnAfterUpdate"
OnExitEditMode="WebGrid1_OnExitEditMode" OnEnterEditMode="WebGrid1_OnEnterEditMode" OnRowSelect="WebGrid1_OnRowSelect" OnAfterDelete="WebGrid1_OnAfterDelete"
OnKeyDown="WebGrid1_DoKeyDown" OnCellDblClick="WebGrid1_OnCellDblClick" OnUnhandledError ="WebGrid1_OnUnhandledError"
OnBeginRowEditing="WebGrid1_OnBeginRowEditing" OnEditKeyDown="WebGrid1_OnEditKeyDown"
OnRowValidate="WebGrid1_OnRowValidate" OnAfterInitialize="WebGridX_OnAfterInitialize" OnLostFocus="WebGrid1_OnLostFocus" />
<FrameStyle BackColor="#EAF3FF">
</FrameStyle>
<TextSettings Language="UseCustom" />
</LayoutSettings>
<RootTable Caption="OrderPositionCollection" DataKeyField="salesorderdetailid">
<Columns>

<ISWebGrid:WebGridColumn Caption="Product" DataMember="productid" Name="productid"
Width="190px" EditType="WebComboNET" WebComboID="WebComboProd" InputRequired="True"
InputRequiredErrorText="Specify the Product." TreatMarkupAsLiteralText="True"
ColumnType="Custom">

All Replies

Hello,

I’m sorry for the late response and I apologize for the inconvenience.
I’ve tried to make a sample project that maybe similar with your scenario.
I made a simple table, called “Sorting” table. The table two fields, ID field (as primary key) & Codes field.
I added data that maybe similar with your scenario. (SortingTable.png)

I bind the table to WebGrid and then I tried to sort the Codes column.
However, it’s works fine on my end. (ResultSorting1.png & ResultSorting2.png)

I attached the database and the sample project, in order to make you easier understand about my sample.

Would you mind to tell me how to replicate this issue? There may be a setting the I miss, in my sample.
Or could you send me your sample project that replicate this issue?

Thank you.
Regards,
Hans.

Thanks for your answer.
The problem is that the column that we try to sorting is a WebCombo

<ISWebGrid:WebGridColumn Caption="Product" DataMember="productid" Name="productid"
Width="190px" EditType="WebComboNET" WebComboID="WebComboProd" InputRequired="True"
InputRequiredErrorText="Specify the Product." TreatMarkupAsLiteralText="True"
ColumnType="Custom">
</ISWebGrid:WebGridColumn>


1 attachment
Hello,

It seems the issue occurs because of difference rendering between the “Product Number” in database and WebGrid.
For example, Product Number in database is “123 758    895”, but in WebGrid become “123 758 895”

Basically when building a Web page is that Web pages don't handle white space characters the same way that word processors do.
When you write your HTML, you can add any number of these white space characters into your HTML. But when you view that HTML in a Web page, one white space will be displayed.

In order for those spaces to display in your web browsers you need to use one of HTML character entities like “&nbsp”

To resolve this issue, please try to add a validation in WebGrid’s InitializeCell server side event.
Here’s the snippet example code:
protected void WebGrid1_InitializeCell(object sender, ISNet.WebUI.WebGrid.CellEventArgs e)
{
	if (e.Cell.Column.Name == "Product Numbers")
	{
		e.Cell.Column.ColumnType = ISNet.WebUI.WebGrid.ColumnType.Custom;
		e.Cell.Text = e.Cell.Value.ToString().Replace(" ", "&nbsp");
	}
}


Hope this helps. Thank you.

Regards,
Hans.



Thanks,
i try to insert in the server side this
protected void WebGrid1_InitializeRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e)
{

if (e.Row.Type == RowType.Record)
{
DataRowView a = (DataRowView)e.Row.DataRow;
WebGridCell productIdCell = e.Row.Cells.GetNamedItem("productid");
productIdCell.Column.ColumnType = ISNet.WebUI.WebGrid.ColumnType.Custom;
string productNumber = (string)a["productnumber"];
productIdCell.Text = productNumber.Replace(" ", " ");
...
But it doesn't work.
Is very strange because in other parts of the application the sorting working ( but they don't use the webcombo component).
Is possibile that it depend because the cell of the product is a WebCombo?

This is the definition of the WebCombo in my code

<ISWebCombo:WebCombo ID="WebComboProd" runat="server" AdditionalSearchFields="ProductName, Speedy_CustProdRefDescription"
DataTextField="ProductNumber"
DataValueField="ProductId" MinCharsToRequest="2" Height="20px"
UseDefaultStyle="True" OnInitializeRow="WebComboProd_InitializeRow"
Width="550px" Latency="200"
OnInitializeDataSource="WebComboProd_InitializeDataSource"
OnInitializeLayout="WebComboProd_InitializeLayout" AllowWildCardSearch="True"
DropDownRows="7" >
<Columns>
<ISWebCombo:WebComboColumn BaseFieldName="productnumber" Name="productnumber" HeaderText="Number"
Width="150" />
<ISWebCombo:WebComboColumn BaseFieldName="productname" Name="productname" HeaderText="Name"
Width="250" />
<ISWebCombo:WebComboColumn BaseFieldName="productid" Name="productid" Hidden="true"
RenderOnHidden="true" />
<ISWebCombo:WebComboColumn BaseFieldName="Quantity" Name="Quantity" Hidden="true"
RenderOnHidden="True" />
<ISWebCombo:WebComboColumn BaseFieldName="Speedy_MinimumSellingPrice" Hidden="True"
Name="Speedy_MinimumSellingPrice" RenderOnHidden="True" />
<ISWebCombo:WebComboColumn BaseFieldName="Speedy_MinimumSellingQuantity" Hidden="True"
Name="Speedy_MinimumSellingQuantity" RenderOnHidden="True" />
<ISWebCombo:WebComboColumn BaseFieldName="Speedy_CustProdRefDescription" Name="Speedy_CustProdRefDescription"
HeaderText="Customer reference" Width="150" />
<ISWebCombo:WebComboColumn BaseFieldName="canModifyCustProdRef" DataType="System.Boolean"
Name="canModifyCustProdRef" RenderOnHidden="True" Hidden="True" />
<ISWebCombo:WebComboColumn BaseFieldName="StateCode"
Name="StateCode" RenderOnHidden="True" Hidden="True" />
<ISWebCombo:WebComboColumn BaseFieldName="speedy_referenceallowed" Name="speedy_referenceallowed"
HeaderText="ReferenceAllowed" Hidden="true" RenderOnHidden="True" />
<ISWebCombo:WebComboColumn BaseFieldName="speedy_directdelivery" Name="speedy_directdelivery"
HeaderText="DirectDelivery" Width="120" RenderOnHidden="True" />
<ISWebCombo:WebComboColumn BaseFieldName="statuscodename" Name="statuscodename" HeaderText="StatusCode" Width="120" />
<ISWebCombo:WebComboColumn BaseFieldName="speedy_special" Name="speedy_special"
HeaderText="special" Width="120" Hidden="true" RenderOnHidden="True" />
<ISWebCombo:WebComboColumn BaseFieldName="speedy_prodgroupdes" Name="speedy_prodgroupdes"
HeaderText="speedy_productgroupdes c" Width="120" />
<ISWebCombo:WebComboColumn HeaderText="Url" BaseFieldName="speedy_urltds" Name="speedy_urltds" Hidden="true"
RenderOnHidden="true">
</ISWebCombo:WebComboColumn>
</Columns>
<FlyPostBackSettings PostControlState="False" PostViewState="False" />
<LayoutSettings ComboMode="MultipleColumns" EntryMode="AutoComplete" LoadMoreKeyGesture="DownArrowKey"
>
<ClientSideEvents OnAfterItemSelected="WebComboProd_OnAfterItemSelected"
OnAfterResponseProcess="WebComboProd_OnAfterResponseProcess" />
</LayoutSettings>
</ISWebCombo:WebCombo>

and the WebCombo was insert into WebGrid in this way


<ISWebGrid:WebGridColumn Caption="Product" DataMember="productid" Name="productid"
Width="190px" EditType="WebComboNET" WebComboID="WebComboProd" InputRequired="True"
InputRequiredErrorText="Specify the Product." TreatMarkupAsLiteralText="True"
ColumnType="Custom">

</ISWebGrid:WebGridColumn>


I try to replace the webcombo with a simple WebGridColumn


<ISWebGrid:WebGridColumn Caption="Product Number" DataMember="productnumber" HiddenDataMember="productid" Name="productnumber" ColumnType="Custom" TreatMarkupAsLiteralText="true" Visible="true" Width="100px">
</ISWebGrid:WebGridColumn>


and it works.

So i think it depends of the setting of WebCombo and seems that the sorting was made for the productid ( GUID ) and not for the product number ( text)






Thanks


I find the solution, i insert this code

SortKeyField = "productnumber"

in the webcombo

<ISWebGrid:WebGridColumn Caption="Product" DataMember="productid" Name="productid" SortKeyField = "productnumber"
Width="190px" EditType="WebComboNET" WebComboID="WebComboProd" InputRequired="True"
InputRequiredErrorText="Specify the Product." TreatMarkupAsLiteralText="True"
ColumnType="Custom">

</ISWebGrid:WebGridColumn>

thanks

Hello,

I’m glad to hear that you have found the solution for this issue.
Should you have further question, please do not hesitate to contact us.

Thank you.

Regards,
Hans.

All times are GMT -5. The time now is 3:51 PM.
Previous Next