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

Resize The Grid Header For Session

9 Answers 237 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vimal Kumar
Top achievements
Rank 1
Vimal Kumar asked on 24 Feb 2009, 04:32 AM
Hi There,

I working on telerik. I want to maintain the grid header resized from client for that session. For that i provide the grid header resizing facility from client side. For that i used the coding:

 using System; 
using System.Collections; 
using System.IO; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using Telerik.Web.UI; 
 
namespace WebApplication1 
 public class GridSettingsPersister 
 private RadGrid gridInstance; 
 
 public GridSettingsPersister( RadGrid gridInstance ) 
 { 
  this.gridInstance = gridInstance; 
 } 
  
 //this method should be called on Render 
 public string SaveSettings() 
 { 
  object[] gridSettings = new object[4]; 
 
  //Save groupBy 
  GridGroupByExpressionCollection groupByExpressions = gridInstance.MasterTableView.GroupByExpressions; 
  object[] groupExpressions = new object[groupByExpressions.Count]; 
 
  int count = 0
  foreach( GridGroupByExpression expression in groupByExpressions ) 
  { 
   groupExpressions[count] = ((IStateManager)expression).SaveViewState(); 
   count++; 
  } 
 
  gridSettings[0] = groupExpressions; 
 
  //Save sort expressions 
  gridSettings[1] = ((IStateManager)gridInstance.MasterTableView.SortExpressions).SaveViewState(); 
 
  //Save columns order 
  int columnsLength = gridInstance.MasterTableView.Columns.Count + 
   gridInstance.MasterTableView.AutoGeneratedColumns.Length; 
 
  Pair [] columnOrder = new Pair[ columnsLength ]; 
 
  ArrayList allColumns = new ArrayList( columnsLength ); 
 
  allColumns.AddRange(gridInstance.MasterTableView.Columns ); 
  allColumns.AddRange(gridInstance.MasterTableView.AutoGeneratedColumns); 
 
  int i = 0
  foreach( GridColumn column in allColumns ) 
  { 
   Pair p = new Pair(); 
   p.First = column.OrderIndex; 
   p.Second = column.HeaderStyle.Width; 
 
   columnOrder[i] = p; 
 
   i++; 
  } 
 
  gridSettings[2] = columnOrder; 
 
 //Save filter expression 
  gridSettings[3] = (object)gridInstance.MasterTableView.FilterExpression; 
 
  LosFormatter formatter = new LosFormatter(); 
 
  StringWriter writer = new StringWriter(); 
  formatter.Serialize( writer, gridSettings ); 
 
  return writer.ToString(); 
 
 } 
 
 //this method should be called on PageInit 
 public void LoadSettings( string settings ) 
 { 
  LosFormatter formatter = new LosFormatter(); 
  StringReader reader = new StringReader( settings ); 
 
  object[] gridSettings = (object[])formatter.Deserialize( reader ); 
 
  //Load groupBy 
  GridGroupByExpressionCollection groupByExpressions = this.gridInstance.MasterTableView.GroupByExpressions; 
  groupByExpressions.Clear(); 
 
  object[] groupExpressionsState = (object[])gridSettings[0]; 
 
  int count = 0
  foreach( object obj in groupExpressionsState ) 
  { 
   GridGroupByExpression expression = new GridGroupByExpression(); 
   ((IStateManager)expression).LoadViewState( obj ); 
   groupByExpressions.Add( expression ); 
   count++; 
  } 
 
  //Load sort expressions 
  this.gridInstance.MasterTableView.SortExpressions.Clear(); 
  ((IStateManager)this.gridInstance.MasterTableView.SortExpressions).LoadViewState( gridSettings[1] ); 
 
  //Load columns order 
  int columnsLength = this.gridInstance.MasterTableView.Columns.Count + 
   this.gridInstance.MasterTableView.AutoGeneratedColumns.Length; 
 
  Pair [] columnOrder = (Pair[])gridSettings[2]; 
 
  if ( columnsLength == columnOrder.Length) 
  { 
   ArrayList allColumns = new ArrayList( columnsLength ); 
 
   allColumns.AddRange(this.gridInstance.MasterTableView.Columns ); 
   allColumns.AddRange(this.gridInstance.MasterTableView.AutoGeneratedColumns); 
 
   int i = 0
   foreach( GridColumn column in allColumns ) 
   { 
    column.OrderIndex = (int)columnOrder[i].First; 
    column.HeaderStyle.Width = (Unit)columnOrder[i].Second; 
 
    i++; 
   } 
  } 
  //Load filter expression 
  this.gridInstance.MasterTableView.FilterExpression = (string)gridSettings[3]; 
 
 } 
}  
By using this coding i am able to maintain the grid resizing for the session. But the problem i am facing is, i have provide facility in my grid that, when i will double click on any of the row in the grid it will move to  edit page, And when i will come back to this page grid header use to come its original size. It's not maintaining the session. I just wanna the grid should maintain the header resized on double click also. Can anybody tell me the way to maintain the session on grid double click also.

Regards:
Vimal Kumar Srivastava
Madhepura, Bihar
Email Id: vimaltech04@gmail.com


9 Answers, 1 is accepted

Sort by
0
Vimal Kumar
Top achievements
Rank 1
answered on 24 Feb 2009, 06:16 AM
Hi there,

Actually the thing is that, in my page i am having one add button, which redirect the page to the next page, and when i will back to this page, the session will maintain. But the same time i have given double click facility to my grid, so that i will double click on my grid row i will be able to move to the next page for edit the row, but here if i will come back to the page, i am seeing the session is not maintain. I Can't able to find in the same page if it's working for add button, then why it's not working for double click. For double click i am mapping with radajax, i am not sure, whether it is not working because of radajax or some thing else. So please let me know the problem. I have already sent my sample code. Waiting for reply..........

Regards:
Vimal Kumar Srivastava
Email Id: vimaltech04@gmail.com



0
Vimal Kumar
Top achievements
Rank 1
answered on 26 Feb 2009, 05:45 AM
Hi there,

Can anybody help me to know that whether Ajax mapping is supporting to maintain the Grid Header For Session or not. Cause i did my work by using ajax mapping and its not supporting. i did my coding like:-
In aspx page:- 
 
<script type="text/javascript"
          //------ Row Double Click ------ // 
          function RowDblClick(sender, eventArgs) 
          { 
            var index = eventArgs.get_itemIndexHierarchical();                
            document.getElementById("radGridClickedRowIndex").value = index;       
            $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RowDblClicked");             
          } 
        </script> 
 
 
And in aspx.cs page : - 
 
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
    { 
        int radGridClickedRowIndex; 
        //get the rowindex 
        radGridClickedRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]); 
        GridItem gdi = rgIssueList.Items[radGridClickedRowIndex]; 
        //get the key values issue_id and assigned_to 
        string strIssueId = rgIssueList.Items[radGridClickedRowIndex].GetDataKeyValue("issue_id").ToString(); 
        string strAssignedto = rgIssueList.Items[radGridClickedRowIndex].GetDataKeyValue("assigned_to").ToString(); 
        Session[ConstValues.ASSIGNED_TO] = strAssignedto; 
        //Redirect to issue edit page 
        Response.Redirect("IssueEdit.aspx?act=ed&iid=" + strIssueId, false); 
 
    } 

Regards:
Vimal Kumar Srivastava
Email Id: vimaltech04@gmail.com


0
Tsvetoslav
Telerik team
answered on 27 Feb 2009, 07:58 AM
Hello Vimal Kumar,

I tested your GridSettingsPersister class in a sample application of mind and it is working all right with ajax. Could you send your complete aspx and code behind. Thank you.

Best wishes,
Tsvetoslav
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.
0
Vimal Kumar
Top achievements
Rank 1
answered on 27 Feb 2009, 03:29 PM
Hi Tsvetoslav,

Thanks for reviewing my code. Here i am showing you my aspx and code behind page :
Aspx code 
 
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" 
    CodeFile="IssueList.aspx.cs" Inherits="IssueList" Title="Datascan, LP - Issue Tracker" %> 
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"
    <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1"
        
        <script type="text/javascript">   
        //------ Grid Resize ------ //                   
        function GridCreated()    
        { 
          var scrollArea = document.getElementById("<%= rgIssueList.ClientID %>" + "_GridData");                           
          var dataHeight =  document.getElementById("ctl00_ContentPlaceHolder1_rgIssueList_ctl00");            
               
          if(dataHeight.clientHeight < 350
          {  
            scrollArea.style.height = dataHeight.clientHeight + 20 + "px"; 
            scrollArea.style.overflow = "auto"
          } 
        } 
        </script> 
 
        <script type="text/javascript"
          //------ Row Double Click ------ // 
          function RowDblClick(sender, eventArgs) 
          { 
            var index = eventArgs.get_itemIndexHierarchical();                
            document.getElementById("radGridClickedRowIndex").value = index;       
            $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RowDblClicked");             
          } 
        </script> 
 
        <script type="text/javascript"
          //------ Row Right Click ------ //  
          function RowContextMenu(sender, eventArgs) 
          {               
            var menu = $find("<%=RadMenu1.ClientID %>"); 
            var evt = eventArgs.get_domEvent(); 
            if(evt.target.tagName == "INPUT" || evt.target.tagName == "A") 
            { 
              return; 
            }   
            var index = eventArgs.get_itemIndexHierarchical(); 
            document.getElementById("radGridClickedRowIndex").value = index
                
            sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true); 
            menu.show(evt); 
           
            evt.cancelBubble = true
            evt.returnValue = false
            if (evt.stopPropagation) 
            { 
              evt.stopPropagation(); 
              evt.preventDefault(); 
            } 
          } 
        </script> 
 
        <script type="text/javascript"
          //------ Enter key for search button ------ //  
          function clickButton(e) 
          {                
            var eevt = e ? e : window.event; 
            var bt = document.getElementById('btnSrch');       
            if (bt) 
            { 
              if (evt.keyCode == 13) 
              { 
                bt.click();  
                return false; 
              } 
            }  
          } 
        </script> 
 
    </telerik:RadScriptBlock> 
    <h2> 
        Issues</h2> 
    <table bgcolor="LightSteelBlue" cellpadding="0" cellspacing="0"
        <tr> 
            <td colspan="9" style="height: 15px"
            </td> 
        </tr> 
        <tr> 
            <td width="10"
                &nbsp;</td> 
            <td> 
                <table cellpadding="3" cellspacing="0"
                    <tr> 
                        <td style="height: 29px"
                            <asp:Button ID="btnAdd" runat="server" Text="Add" CssClass="styButton" OnClick="btnAdd_Click" /></td
                        <td style="height: 29px"
                            <asp:Button ID="Button1" runat="server" Text="Edit" CssClass="styButton" OnClick="Button1_Click1" /></td
                        <td style="height: 29px"
                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="styButton" OnClick="btnCancel_Click"
                            </asp:Button></td
                        <td class="styLabel" style="height: 29px"
                            Search Text:</td> 
                        <td style="height: 29px"
                            <asp:TextBox ID="txtSearch" runat="server" CssClass="styDefault" onkeypress="javascript:return clickButton(event)"></asp:TextBox></td
                        <td class="styLabel" style="height: 29px"
                            View:</td> 
                        <td style="height: 29px"
                            <asp:DropDownList ID="ddlView" AutoPostBack="true" runat="server" EnableViewState="False" 
                                OnChange="Search()"
                                <asp:ListItem>Migrate</asp:ListItem> 
                                <asp:ListItem>Unassigned</asp:ListItem> 
                                <asp:ListItem Selected="True">Open issues by priority</asp:ListItem> 
                                <asp:ListItem>Open issues by customer</asp:ListItem> 
                                <asp:ListItem>Open test issues</asp:ListItem> 
                                <asp:ListItem>Recently changed</asp:ListItem> 
                                <asp:ListItem>Scanner group</asp:ListItem> 
                                <asp:ListItem>Server group</asp:ListItem> 
                                <asp:ListItem>Test group</asp:ListItem> 
                                <asp:ListItem>All</asp:ListItem> 
                            </asp:DropDownList></td
                        <td style="height: 29px"
                            <input id="btnSrch" class="styButton" type="button" value="Search" onclick="Search()" /> 
                        </td> 
                    </tr> 
                </table> 
            </td> 
            <td width="10"
                &nbsp;</td> 
        </tr> 
        <tr> 
            <td width="10"
                &nbsp;</td> 
            <td> 
                <table cellspacing="0" cellpadding="0"
                    <tr> 
                        <td> 
                            <telerik:RadGrid Width="70%" ID="rgIssueList" runat="server" GridLines="Horizontal" 
                                Skin="WebBlue" AllowSorting="True" AllowPaging="True" PageSize="15" AutoGenerateColumns="false" 
                                OnNeedDataSource="rgIssueList_NeedDataSource" OnPreRender="rgIssueList_PreRender" 
                                OnUnload="rgIssueList_Unload" OnLoad="rgIssueList_Load" OnSelectedIndexChanged="rgIssueList_SelectedIndexChanged" 
                                OnEditCommand="rgIssueList_EditCommand"
                                <ClientSettings ReorderColumnsOnClient="True" AllowColumnsReorder="True" EnableRowHoverStyle="true"
                                    <ClientEvents OnRowDblClick="RowDblClick" OnRowContextMenu="RowContextMenu"
                                    </ClientEvents> 
                                    <DataBinding EnableCaching="True" /> 
                                    <Resizing EnableRealTimeResize="true" ClipCellContentOnResize="true" AllowRowResize="false" 
                                        ResizeGridOnColumnResize="false" AllowColumnResize="True"></Resizing> 
                                    <Selecting AllowRowSelect="True"></Selecting> 
                                    <Scrolling AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="true" EnableVirtualScrollPaging="True" /> 
                                </ClientSettings> 
                                <MasterTableView TableLayout="Fixed" Width="100%" DataKeyNames="issue_id,assigned_to"
                                    <Columns> 
                                        <telerik:GridBoundColumn DataField="issue_id" HeaderText="Issue" SortExpression="issue_id" 
                                            UniqueName="issue_id" HeaderStyle-Width="40px" ItemStyle-Width="40px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="customer_desc" HeaderText="Customer" SortExpression="customer_desc" 
                                            UniqueName="customer_desc" HeaderStyle-Width="100px" ItemStyle-Width="100px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="job_number" HeaderText="Job" SortExpression="job_number" 
                                            UniqueName="job_number" HeaderStyle-Width="35px" ItemStyle-Width="35px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="job_desc" HeaderText="Job Desc" SortExpression="job_desc" 
                                            UniqueName="job_desc" HeaderStyle-Width="70px" ItemStyle-Width="70px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="system" HeaderText="System" SortExpression="system" 
                                            UniqueName="system" HeaderStyle-Width="70px" ItemStyle-Width="70px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="subsystem" HeaderText="Sub System" SortExpression="subsystem" 
                                            UniqueName="subsystem" HeaderStyle-Width="70px" ItemStyle-Width="70px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="title" HeaderText="Title" SortExpression="title" 
                                            UniqueName="title" HeaderStyle-Width="250px" ItemStyle-Width="250px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="due_date" HeaderText="Due" SortExpression="due_date" 
                                            DataFormatString="{0:MM/dd/yyyy}" UniqueName="due_date" HeaderStyle-Width="75px" 
                                            ItemStyle-Width="75px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="priority" HeaderText="Priority" SortExpression="priority" 
                                            UniqueName="priority" HeaderStyle-Width="70px" ItemStyle-Width="70px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="status" HeaderText="Status" SortExpression="status" 
                                            UniqueName="status" HeaderStyle-Width="90px" ItemStyle-Width="90px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="assigned_to" HeaderText="Assigned" SortExpression="assigned_to" 
                                            UniqueName="assigned_to" HeaderStyle-Width="90px" ItemStyle-Width="90px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="tester" HeaderText="Tester" SortExpression="tester" 
                                            UniqueName="tester" HeaderStyle-Width="90px" ItemStyle-Width="90px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="last_modified" HeaderText="Modified" SortExpression="last_modified" 
                                            DataFormatString="{0:MM/dd/yyyy}" UniqueName="last_modified" HeaderStyle-Width="75px" 
                                            ItemStyle-Width="75px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="last_modified_by" HeaderText="Modified By" SortExpression="last_modified_by" 
                                            UniqueName="last_modified_by" HeaderStyle-Width="90px" ItemStyle-Width="90px"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="created_by" HeaderText="Created by" SortExpression="created_by" 
                                            UniqueName="created_by" HeaderStyle-Width="90px" ItemStyle-Width="90px"
                                        </telerik:GridBoundColumn> 
                                    </Columns> 
                                </MasterTableView> 
                                <ItemStyle Font-Size="9pt" HorizontalAlign="left" /> 
                                <AlternatingItemStyle Font-Size="9pt" HorizontalAlign="left" /> 
                                <HeaderStyle Font-Bold="true" Font-Size="9pt" HorizontalAlign="left" /> 
                                <PagerStyle Visible="false" /> 
                            </telerik:RadGrid> 
                        </td> 
                    </tr> 
                    <tr> 
                        <td> 
                            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
                                <AjaxSettings> 
                                    <telerik:AjaxSetting AjaxControlID="ddlView"
                                        <UpdatedControls> 
                                            <telerik:AjaxUpdatedControl ControlID="rgIssueList" LoadingPanelID="AjaxLoadingPanel1" /> 
                                        </UpdatedControls> 
                                    </telerik:AjaxSetting> 
                                    <telerik:AjaxSetting AjaxControlID="rgIssueList"
                                        <UpdatedControls> 
                                            <telerik:AjaxUpdatedControl ControlID="rgIssueList" LoadingPanelID="AjaxLoadingPanel1" /> 
                                        </UpdatedControls> 
                                    </telerik:AjaxSetting> 
                                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                                        <UpdatedControls> 
                                           <telerik:AjaxUpdatedControl ControlID="rgIssueList" LoadingPanelID="AjaxLoadingPanel1" /> 
                                        </UpdatedControls> 
                                    </telerik:AjaxSetting> 
                                </AjaxSettings> 
                            </telerik:RadAjaxManager> 
                            <telerik:RadAjaxLoadingPanel ID="AjaxLoadingPanel1" runat="server" Height="100%" 
                                BackColor="#E0E0E0" Width="100%" Transparency="50"
                                <img alt="Loading..." src="Images/ajax-loader.gif" style="border: 0;" /> 
                            </telerik:RadAjaxLoadingPanel> 
                            <input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" /> 
                            <telerik:RadContextMenu ID="RadMenu1" runat="server" Skin="Gray" OnItemClick="RadMenu1_ItemClick"
                                <Items> 
                                    <telerik:RadMenuItem Text="View" runat="server" /> 
                                </Items> 
                                <CollapseAnimation Duration="200" Type="OutQuint" /> 
                            </telerik:RadContextMenu> 
                        </td> 
                    </tr> 
                </table> 
            </td> 
            <td width="10"
                &nbsp;</td> 
        </tr> 
        <tr> 
            <td colspan="9" align="left" bgcolor="lightcyan" style="height: 18px"
                <span class="styLabel">Status:</span> 
                <asp:Label ID="lblStatus" runat="server" ForeColor="Green" CssClass="styDefault"></asp:Label> 
            </td> 
        </tr> 
    </table> 
    <asp:ObjectDataSource ID="odsIssueList" runat="server" OldValuesParameterFormatString="original_{0}" 
        SelectMethod="GetData" TypeName="IssueDALTableAdapters.IssueListTableAdapter"
        <SelectParameters> 
            <asp:ControlParameter ControlID="txtSearch" Name="search_string" PropertyName="Text" 
                Type="String" /> 
            <asp:ControlParameter ControlID="ddlView" Name="view_name" PropertyName="SelectedValue" 
                Type="String" /> 
        </SelectParameters> 
    </asp:ObjectDataSource> 
</asp:Content> 
 
 
 
 
 
 
 
 
Aspx.cs code : 
 
using System; 
using System.Data; 
using System.Configuration; 
using System.Collections; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
using System.Text; 
using Telerik.Web; 
using Telerik.Web.UI; 
 
public partial class IssueList : System.Web.UI.Page 
    #region Declaration 
    DataView dvIssueList; 
    #endregion 
 
    #region To maintain the Grid state 
 
    protected override void Render(HtmlTextWriter writer) 
    { 
        try 
        { 
            base.Render(writer); 
            SetGrid obj = new SetGrid(); 
            Session["GridState"] = obj.SavePetNames(rgIssueList, "rgIssueList"); 
        } 
        catch (Exception ex) 
        { 
            //strErr = ex.ToString(); 
        } 
    } 
 
 
    protected void Page_Init(object sender, EventArgs e) 
    { 
        try 
        { 
            if (Session["GridState"] != null) 
            { 
                GridSettings settings = new GridSettings(rgIssueList); 
                settings.LoadSettings(Session["GridState"].ToString()); 
            } 
        } 
        catch (Exception ex) 
        { 
            //strErr = ex.ToString(); 
        } 
    } 
 
    #endregion 
 
    #region Page Load 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        ClientScriptManager csm = Page.ClientScript; 
        if (!csm.IsClientScriptBlockRegistered("Search")) 
        { 
            StringBuilder sb = new StringBuilder(); 
            if (ddlView.SelectedIndex == 0) 
            { 
                ddlView.SelectedIndex = 6
            } 
            sb.Append("<script language=javascript>\n  function Search()\n  {\n    document.location = \"IssueList.aspx?"); 
            sb.Append("st=\" + document.forms[0]." + txtSearch.ClientID + ".value + \"&ddv=\" + document.forms[0]." + 
                ddlView.ClientID + ".selectedIndex \n  }\n</script>"); 
            csm.RegisterClientScriptBlock(typeof(Page), "Search", sb.ToString()); 
        } 
 
        //Response.Write(Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName].Value); 
        if (Request.QueryString["st"] != null) 
        { 
            if (Request.QueryString["st"].ToString() != string.Empty) 
                txtSearch.Text = Request.QueryString["st"].ToString(); 
        } 
 
        if (Request.QueryString["ddv"] != null) 
        { 
            if (!Page.IsPostBack) 
                ddlView.SelectedIndex = Convert.ToInt32(Request.QueryString["ddv"]); 
        } 
 
        if (!IsPostBack) 
        { 
            //dvIssueList = CheckViewState(); 
            //rgIssueList.VirtualItemCount = 528;//dvIssueList.Table.Rows.Count; 
        } 
        txtSearch.Focus(); 
    } 
    #endregion 
 
    #region CheckViewState 
    private DataView CheckViewState() 
    { 
        try 
        { 
            //Check View State For Job Columns 
            if (ViewState["IssueList"] == null) 
            { 
                dvIssueList = ((DataView)(odsIssueList.Select())); 
                // Create the column 
                DataColumn dataColumn = new DataColumn(); 
                dataColumn.DataType = System.Type.GetType("System.Int32"); 
                dataColumn.ColumnName = "RowIndex"
                // Add it to dataTable 
                dvIssueList.Table.Columns.Add(dataColumn); 
                // Populate it 
                int rowIndex = 1
                foreach (DataRow row in dvIssueList.Table.Rows) 
                { 
                    row["RowIndex"] = rowIndex++; 
                } 
                ViewState["IssueList"] = dvIssueList; 
            } 
            else 
            { 
                dvIssueList = (DataView)ViewState["IssueList"]; 
            } 
        } 
        catch (Exception ex) 
        { 
            // Write to Log File 
            //DNLogger objWriteLog = new DNLogger(); 
            //objWriteLog.LogInfo(ex); 
        } 
        return dvIssueList; 
    } 
    #endregion 
 
    #region Add Issue 
    protected void btnAdd_Click(object sender, EventArgs e) 
    { 
        Response.Redirect("IssueEdit.aspx?act=ad"); 
    } 
    #endregion 
 
    #region Search Issue 
    protected void btnSearch_Click(object sender, EventArgs e) 
    { 
        //Response.Redirect("IssueList.aspx?ddv=" + ddlView.SelectedIndex); 
    } 
    #endregion 
 
    #region Cancel Issue 
    protected void btnCancel_Click(object sender, EventArgs e) 
    { 
        CrumbsBLL BCTrail = (CrumbsBLL)Context.Session["bc"]; 
        string strUrl = BCTrail.GetCrumb(); 
        Context.Session["bc"] = BCTrail; 
        Response.Redirect(strUrl); 
    } 
    #endregion 
 
    #region Need Data Source 
    protected void rgIssueList_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
    { 
        try 
        { 
            //Bind The Data With Grid 
            dvIssueList = ((DataView)(odsIssueList.Select())); 
            //dvIssueList.Table.DefaultView.RowFilter = "RowIndex > " + rgIssueList.CurrentPageIndex * rgIssueList.PageSize + " AND  RowIndex <= " + ((rgIssueList.CurrentPageIndex + 1) * rgIssueList.PageSize) + ""; 
            rgIssueList.DataSource = dvIssueList.Table.DefaultView; 
        } 
        catch (Exception ex) 
        { 
            // Write to Log File 
            //DNLogger objWriteLog = new DNLogger(); 
            //objWriteLog.LogInfo(ex); 
        } 
    } 
    #endregion 
 
    #region Right click to view the item 
    protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e) 
    { 
        int radGridClickedRowIndex; 
        //get the rowindex 
        radGridClickedRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]); 
        GridItem gdi = rgIssueList.Items[radGridClickedRowIndex]; 
        //get the key values issue_id and assigned_to 
        string strIssueId = rgIssueList.Items[radGridClickedRowIndex].GetDataKeyValue("issue_id").ToString(); 
        string strAssignedto = rgIssueList.Items[radGridClickedRowIndex].GetDataKeyValue("assigned_to").ToString(); 
        switch (e.Item.Text) 
        { 
            case "View": 
                Session[ConstValues.ASSIGNED_TO] = strAssignedto; 
                //Redirect to issue view page 
                Response.Redirect("IssueView.aspx?iid=" + strIssueId, false); 
                break; 
        } 
    } 
    #endregion 
 
    #region create AjaxRequest for row double click to edit the item 
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
    { 
         
        int radGridClickedRowIndex; 
        //get the rowindex 
        radGridClickedRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]); 
        GridItem gdi = rgIssueList.Items[radGridClickedRowIndex]; 
        //get the key values issue_id and assigned_to 
        string strIssueId = rgIssueList.Items[radGridClickedRowIndex].GetDataKeyValue("issue_id").ToString(); 
        string strAssignedto = rgIssueList.Items[radGridClickedRowIndex].GetDataKeyValue("assigned_to").ToString(); 
        Session[ConstValues.ASSIGNED_TO] = strAssignedto; 
        //Redirect to issue edit page 
        Response.Redirect("IssueEdit.aspx?act=ed&iid=" + strIssueId, false); 
    } 
    #endregion 
 
    #region Grid Prerender 
    protected void rgIssueList_PreRender(object sender, EventArgs e) 
    { 
         
        SetGrid obj = new SetGrid(); 
        Session["GridState"] = obj.SavePetNames(rgIssueList, "rgIssueList"); 
        CrumbsBLL BCTrail = null
        if (Context.Session["bc"] == null) 
            BCTrail = new CrumbsBLL(); 
        else 
            BCTrail = (CrumbsBLL)Context.Session["bc"]; 
 
        GridSortExpression expression = new GridSortExpression(); 
        if (BCTrail.CrumbPickedUp && BCTrail.CrumbHasSortPageInfo()) 
        { 
            expression.FieldName = BCTrail.GridSortExpression(); 
            expression.SortOrder = (GridSortOrder)BCTrail.GridSortDirection(); 
            rgIssueList.CurrentPageIndex = BCTrail.GridPage(); 
            rgIssueList.MasterTableView.Rebind(); 
        } 
 
        BCTrail.AddCrumb("IssueList.aspx", "st=" + txtSearch.Text + "&ddv=" + ddlView.SelectedIndex, "Issue List", 
            rgIssueList.CurrentPageIndex, expression.FieldName, (SortDirection)expression.SortOrder); 
 
        Context.Session["bc"] = BCTrail; 
        
    } 
    #endregion 
 
    #region To Maintain The Changes For That Particular Session 
    protected void rgIssueList_Unload(object sender, EventArgs e) 
    { 
        SetGrid obj = new SetGrid(); 
        Session["GridState"] = obj.SavePetNames(rgIssueList, "rgIssueList"); 
    } 
 
    protected void rgIssueList_Load(object sender, EventArgs e) 
    { 
        SetGrid obj = new SetGrid(); 
        Session["GridState"] = obj.SavePetNames(rgIssueList, "rgIssueList"); 
    } 
    #endregion 
 
    #region SelectedIndexChanged 
    protected void rgIssueList_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        SetGrid obj = new SetGrid(); 
        Session["GridState"] = obj.SavePetNames(rgIssueList, "rgIssueList"); 
        int radGridClickedRowIndex; 
        //get the rowindex 
        radGridClickedRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]); 
        GridItem gdi = rgIssueList.Items[radGridClickedRowIndex]; 
        //get the key values issue_id and assigned_to 
        string strIssueId = rgIssueList.Items[radGridClickedRowIndex].GetDataKeyValue("issue_id").ToString(); 
        string strAssignedto = rgIssueList.Items[radGridClickedRowIndex].GetDataKeyValue("assigned_to").ToString(); 
        Session[ConstValues.ASSIGNED_TO] = strAssignedto; 
        //Redirect to issue edit page 
        Response.Redirect("IssueEdit.aspx?act=ed&iid=" + strIssueId, false); 
    } 
    #endregion 
 
    #region EditCommand 
    protected void rgIssueList_EditCommand(object source, GridCommandEventArgs e) 
    { 
        
    } 
    #endregion 
 
    #region Edit Issue 
    protected void Button1_Click1(object sender, EventArgs e) 
    { 
        
    } 
    #endregion 
 
 

Waiting for your reply.

Regards:
Vimal Kumar Srivastava
Email Id: vimaltech04@gmail.com

0
Vimal Kumar
Top achievements
Rank 1
answered on 02 Mar 2009, 05:14 AM
Hi Tsvetoslav,

As you asked, i have sent you my aspx page as well as code behind page. But still waiting for any response from your side.

Regards:
Vimal Kumar Srivastava
Email Id: vimaltech04@gmail.com
0
Tsvetoslav
Telerik team
answered on 03 Mar 2009, 02:36 PM
Hello Vimal Kumar,

In order to persist the header with settings of the grid you have to find a way on each ajax request to pass the new-header-widths information to the server so that it is availale to the persister object to save in the session. When resizing the columns on the client, there is no way for the grid to automatically know on the server what the new widths are. That's why you can, for example, intercept the ColumnResized client event of the grid, collect the new width for each column when resized, and pass this information as an argument to the ajaxRequest method.

I hope this helps.

Please, note that the 2nd and 3rd of March are Bulgarian national holidays and we are not in a postion to guarantee a timely response to support tickets during this period.

Best Regards,
Tsvetoslav
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.
0
Vimal Kumar
Top achievements
Rank 1
answered on 12 Mar 2009, 05:48 AM
Hi Tsvetoslav,

As you suggest me, i followed the way, And it's working as i wished. But i felt it's very slow. It's taking much time, when i use to resize the column width. I just wanna to know, is there any other way available to solve this problem. If so, please let me know. Here i am posting the coding which helps me to come out of this problem:
Aspx: 
----- 
function ColumnResized(sender, eventArgs) 
          {             
            document.getElementById("radGridClickedRowIndex").value = "Resized";       
            $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("ColumnResized");             
          } 
 
 
aspx.cs 
------- 
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
    { 
            if (Request.Form["radGridClickedRowIndex"].ToLower() != "resized") 
            { 
                //Double click  to row edit 
                int radGridClickedRowIndex; 
                //get the rowindex 
                radGridClickedRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]); 
                GridItem gdi = rgIssueList.Items[radGridClickedRowIndex]; 
                //get the key value issue_id  
                string strIssueId = rgIssueList.Items[radGridClickedRowIndex].GetDataKeyValue("issue_id").ToString();                
                //Redirect to issue edit page 
                Response.Redirect("IssueEdit.aspx?act=ed&iid=" + strIssueId, false);                 
            } 
            else 
            { 
                //set the grid column with when its resized  
                SetGrid obj = new SetGrid(); 
                Session["GridState"] = obj.SavePetNames(rgIssueList, "rgIssueList"); 
            }                
    } 



This codes works fine. But if any other way is also available then please let me know.  waiting for your reply....



Thanks & Regards:
Vimal Kumar Srivastava
Email Id: vimaltech04@gmail.com

0
Accepted
Tsvetoslav
Telerik team
answered on 13 Mar 2009, 02:24 PM
Hi Vimal Kumar,

You do not need to make an ajax request each time a column is resized. I believe this might be the reason for the slow-down in performance. Instead, you can collect the new column widths on the client and if they have changed persist them next time a row is double clicked, i.e. next time an ajax request is made for the purpose of redirecting to the edit page.

For your convenience, I am sending you a small sample that employs your grid persister class and persists the column widths as described above.

Best Regards,
Tsvetoslav
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.
0
Vimal Kumar
Top achievements
Rank 1
answered on 18 Mar 2009, 10:37 AM
Hi Tsvetoslav ,

Thanks for your help. It's working fine. Really very happy. It's really working fine.Thanks a lot. Let me know if you wanna to know how and what code i have used.

Thanks & Regards:
Vimal Kumar Srivastava
Email Id: vimaltech04@gmail.com



Tags
GridView
Asked by
Vimal Kumar
Top achievements
Rank 1
Answers by
Vimal Kumar
Top achievements
Rank 1
Tsvetoslav
Telerik team
Share this question
or