Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am using a third party YUI Grid Tool. I want to sort columns of that grid. When I click on Context Menu it does not work. Following is my code. I am using VB.NET as code behind. Please suggest. thanks.

XML
<cc1:YuiGrid ID="YUIGrid1" runat="server" title="List" Width="955px"
                            Height="425px" AutoGenerateColumns="false" ForeColor="black" AutoPostBack="False" EnableEdit="true"
                            EnablePaging="true" PageSize="50" PagingStyle="NavBar" EnableColumnMove="True" EnableDragDrop="True" EnableRowSorting="True"  >
                            <Columns>
                                <cc1:ColModel header="ID" dataIndex="ID" sortable="False" width="50" hidden="true"  />
                                <cc1:ColModel header="Code" dataIndex="Code" sortable="False" width="100" Editable="True"/>
                                <cc1:ColModel header="Inventory Code" dataIndex="InventoryCode" sortable="False" width="100" Editable="True" />
</Columns>
</cc1:YuiGrid>
Posted
Updated 20-Apr-11 6:46am
v4
Comments
Sandeep Mewara 20-Apr-11 10:10am    
Did you try at the thrid party forum?

 
Share this answer
 
Comments
krypsn 22-Apr-11 0:43am    
Thanks for your suggestion. But i already visited these sites.

First Site:- As I told, I am using VB.NET and this site provides code in C#. I tried to convert this code in VB.NET but fails.

Second Site:- The example given in this site, is for normal ASP GridView. I want the same coding for YUI Grid. In that site they used "protected void GvCustomers_RowDataBound(object sender, GridViewRowEventArgs e)" event for sorting, but no such method is available for YUI Grid.
I found one solution but for this I have to give a call to database every time I click on column for sort.

Private Sub GetProductList(ByVal sortColumn As String, ByVal sortDir As String)
       'Deciding sort orders
       Dim sortField As String = sortColumn
       Dim sortOrder As String = sortDir
       Dim sortOrderReverse As String = IIf(sortOrder = "ASC", "DESC", "ASC")
       Dim cn As New SqlConnection(MyConnectionString)
       Dim cm As New SqlCommand
       cn.Open()
       Try
           With cm
               .Connection = cn
               .CommandType = CommandType.Text
               Try
                   Dim sql1 As String = String.Format( _
                       "SELECT TOP 50 * FROM tabProduct ORDER BY {0} {1}", sortField, sortOrder)
                   Dim sql2 As String = String.Format( _
                       "SELECT TOP {0} * FROM ({1})as a ORDER BY {2} {3}", _
                        grdProductList.PageSize, sql1, sortField, sortOrderReverse)
                   Dim sql3 As String = String.Format( _
                       "SELECT * FROM ({0})as b ORDER BY {1} {2}", _
                        sql2, sortField, sortOrder)
                   .CommandText = sql3
                   Dim da As SqlDataAdapter = New SqlDataAdapter(sql3, cn)
                   Dim ds As New DataSet
                   da.Fill(ds, "tabProduct")
                   YUIGrid1.DataSource = ds
                   YUIGrid1.DataBind()
               Catch ex As Exception
               Finally
               End Try

           End With
       Catch ex As Exception
       End Try
       upnlProductListGrid.Update()
   End Sub
Protected Sub grdProductList_PageIndexChanged(ByVal sender As Object, ByVal e As ExtExtenders.PageIndexChangedArgs) Handles grdProductList.PageIndexChanged
      GetProductList(e.sortColumn, e.sortDir)
        End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900