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

dynamic grid sorting not working

0 Answers 3 Views
Grid
This is a migrated thread and some comments may be shown as answers.
rosali
Top achievements
Rank 1
rosali asked on 20 Mar 2017, 10:26 AM

Hi,

I have created a dynamic grid. but sorting not working.

here is my code.

aspx code

<telerik:RadGrid ID="radGridBICheckData" runat="server" SkinID="RadGrid">
<ClientSettings>
<Resizing EnableRealTimeResize="True" ResizeGridOnColumnResize="True" AllowColumnResize="True"
ClipCellContentOnResize="True" AllowResizeToFit="True"></Resizing>
</ClientSettings>
</telerik:RadGrid>

 

code behind

protected void Page_Init(object sender, EventArgs e)
{
try
{
                                
                DefineGridStructure();
}
catch (Exception ex)
{
Logger.Write(ex.Message, "Error", 0);
NISP.Utilities.ErrorPage.ErrorLog(ex);
}
}

private void DefineGridStructure()
{
//Defines the Grid structure
radGridBICheckData.AutoGenerateColumns = false;
radGridBICheckData.AllowMultiRowSelection = true;
radGridBICheckData.AllowFilteringByColumn = true;
radGridBICheckData.GridLines = GridLines.None;
radGridBICheckData.AllowSorting = true;
// radGridBICheckData.EnableViewState = true;
String htmlColor = "#EDEFF1";
Color backColor = ColorTranslator.FromHtml(htmlColor);
radGridBICheckData.AlternatingItemStyle.BackColor = backColor;
String editColor = "#A2A2A2";
Color editbackColor = ColorTranslator.FromHtml(editColor);
radGridBICheckData.MasterTableView.AllowSorting = true;
radGridBICheckData.MasterTableView.AllowCustomSorting = true;
radGridBICheckData.MasterTableView.AllowFilteringByColumn = true;
radGridBICheckData.MasterTableView.AllowPaging = true;
radGridBICheckData.MasterTableView.AllowCustomPaging = true;
// radGridBICheckData.MasterTableView.CanRetrieveAllData = true;
radGridBICheckData.MasterTableView.PagerStyle.AlwaysVisible = true;
radGridBICheckData.MasterTableView.PagerStyle.Position = GridPagerPosition.Bottom;
radGridBICheckData.MasterTableView.PagerStyle.Mode = GridPagerMode.NextPrevNumericAndAdvanced;
radGridBICheckData.ClientSettings.AllowKeyboardNavigation = true;
radGridBICheckData.ClientSettings.Selecting.AllowRowSelect = true;
radGridBICheckData.ClientSettings.Scrolling.AllowScroll = true;
radGridBICheckData.ClientSettings.Scrolling.UseStaticHeaders = true;
radGridBICheckData.ClientSettings.Scrolling.ScrollHeight = Unit.Pixel(390);
radGridBICheckData.FilterMenu.EnableTheming = true;
radGridBICheckData.FilterMenu.CollapseAnimation.Duration = 200;
radGridBICheckData.FilterMenu.CollapseAnimation.Type = AnimationType.OutQuint;
//Add Master table
radGridBICheckData.MasterTableView.Name = "BICheck";
string[] resolutionArr;
if (SessionManager.GetSessionObject("ScreenResolution") != null)
{
resolutionArr = SessionManager.GetSessionObject("ScreenResolution").ToString().Split('*');
ApplicaionResolutionSettings.ResizingGridForResolution(ApplicationConstants.RES_FILE_TEMPLATE_ROW_DEFINITION, resolutionArr, radGridBICheckData, ApplicationConstants.RES_POPUP_SINGLE_GRID);
}

radGridBICheckData.MasterTableView.EnableColumnsViewState = false;
//GridEditCommandColumn col1 = new GridEditCommandColumn();
//col1.ButtonType = GridButtonColumnType.ImageButton;
//col1.UpdateImageUrl = "../App_Themes/Default/Grid/Update.gif";
//col1.EditImageUrl = "../App_Themes/Default/Grid/Edit.gif";
//col1.InsertImageUrl = "../App_Themes/Default/Grid/Insert.gif";
//col1.CancelImageUrl = "../App_Themes/Default/Grid/Cancel.gif";
//col1.Visible = true;
//col1.UniqueName = "EditCommandColumn";
//grid.MasterTableView.Columns.Add(col1);
GridBoundColumn boundColumn;
string uniqueName = string.Empty;
for (int intIndex = 0; intIndex <= 20; intIndex++)
{
boundColumn = new GridBoundColumn();
if (intIndex == 0)
{
uniqueName = "STATUS";
boundColumn.AllowFiltering = false;
// boundColumn.AllowSorting = false;
}
else
{
uniqueName = "Value" + intIndex;
boundColumn.AllowFiltering = true;
// boundColumn.AllowSorting = true;
}

boundColumn.DataField = uniqueName;
boundColumn.HeaderText = "";
boundColumn.UniqueName = uniqueName;
boundColumn.SortExpression = uniqueName;
//boundColumn.AllowFiltering = true;
//boundColumn.AllowSorting = true;
boundColumn.HeaderStyle.Width = Unit.Pixel(120);
radGridBICheckData.MasterTableView.Columns.Add(boundColumn);
}
radGridBICheckData.NeedDataSource += new GridNeedDataSourceEventHandler(this.radGridBICheckData_NeedDataSource);
radGridBICheckData.ItemDataBound += new GridItemEventHandler(this.radGridBICheckData_ItemDataBound);
radGridBICheckData.ItemCommand += new GridCommandEventHandler(this.radGridBICheckData_ItemCommand);
// radGridBICheckData.PreRender += new EventHandler(radGridBICheckData_PreRender);
}

 

thanks in advance.

No answers yet. Maybe you can help?

Tags
Grid
Asked by
rosali
Top achievements
Rank 1
Share this question
or