This is a migrated thread and some comments may be shown as answers.

[Solved] Weird error in Radgrid Sorting..

2 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Natraj T
Top achievements
Rank 1
Natraj T asked on 20 Jul 2009, 12:17 PM

Hi,

I'm using Rad grid in one my page. The page has a master page and I placed the grid in its child page. I'm binding the grid with the below code, since the code is called on the search button click event , we placed this separately
 

function BindUnAssignedPeopleGrid(result) {
var grid = $find("<%= grdUnassigned.ClientID %>")
var masterTableView = grid.get_masterTableView();
RemoveNoRecordRow(masterTableView.get_element());
if (result == null || result == '' || result == 'undefined') {
result = new Array();
}
masterTableView.set_dataSource(result);
masterTableView.dataBind();
}

and the designer page grid

<telerik:RadGrid ID="grdUnassigned" runat="server" Height="253px" AutoGenerateColumns="False"
GridLines="None" AllowMultiRowSelection="True" Skin="Vista" AllowSorting="true" OnSortCommand="grdUnassigned_SortCommand">
<MasterTableView DataKeyNames="PersonID,Name" TableLayout="Fixed" ClientDataKeyNames="PersonID,Name">
<Columns>
<telerik:GridBoundColumn DataField="Name" HeaderText="Name" ItemStyle-Width="100%">
</telerik:GridBoundColumn>
</Columns>
<RowIndicatorColumn>
<HeaderStyle Width="30px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="30px"></HeaderStyle>
</ExpandCollapseColumn>
</MasterTableView>
<ClientSettings AllowColumnHide="True" EnablePostBackOnRowClick="false">
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<FilterMenu EnableTheming="True">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</FilterMenu>
<FilterItemStyle BackColor="#CCFFFF" />
</telerik:RadGrid>

and in serverside sorting( we need everything to be done in client side, help me in this to sort in client side itself)

protected void grdUnassigned_SortCommand(object source, GridSortCommandEventArgs e)
{
try 
{

if (!e.Item.OwnerTableView.SortExpressions.ContainsExpression(e.SortExpression))
 {
GridSortExpression sortExpr = new GridSortExpression();
sortExpr.FieldName = e.SortExpression;
sortExpr.SortOrder = GridSortOrder.Descending;
e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpr);
}
}
catch (Exception ex)
 
{
}}

but when i do sorting i'm getting "Sys.webforms.pagerequestmanagerparserErrorexception " error. please help me to solve this. I need everything to be done in client side.

Thanks in advance

Its urgent please help me ASAP. 

 

 

2 Answers, 1 is accepted

Sort by
0
Natraj T
Top achievements
Rank 1
answered on 21 Jul 2009, 06:27 AM
nobody there to help me,  Ok

I have added the below code
.......
<ClientEvents OnCommand="grdUnassigned_Command" />
................

 and 

var sortGrid = null; //the sort method call the same function again, to avoid that we used this variable
            function grdUnassigned_Command(sender, args) {
                try {
                    if (sortGrid != 1) {
                        if (args.get_commandName() == "Sort") {
                            var masterTableView = sender.get_masterTableView();
                            var sortExpressions = sender.get_masterTableView().get_sortExpressions();
                            var sortExpressionsAsSQL = sortExpressions.toString();
                            sortGrid = 1;
                            masterTableView.sort(sortExpressionsAsSQL);
                        }
                    }
                    sortGrid = null;
                } catch (e) {
                    alert(e);
                }
                finally {
                }
            }

Still I'm getting error, now something like COM error. The above function execuets well, after this function the control goes to some dynamic created scriptmanager page, after that COM error is occured. The sad part is, error is returned as null object, so i'm not able to fighre the error also( we are using page level error set in web.config)

Please help me in this
0
Sebastian
Telerik team
answered on 23 Jul 2009, 12:36 PM
Hi Natraj T,

From your code snippets I see that you bind the grid instance on the client. Therefore, you will need to implement sorting using WebServices or page methods as illustrated on this online demo of the product:

http://demos.telerik.com/aspnet-ajax/grid/examples/client/databinding/defaultcs.aspx

Alternatively, consider implementing declarative client-side binding (if applicable) as demonstrated on this example:

http://demos.telerik.com/aspnet-ajax/grid/examples/client/declarativedatabinding/defaultcs.aspx

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Natraj T
Top achievements
Rank 1
Answers by
Natraj T
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or