I have implemented RadGrid in my project for displaying data. But facing one severe issue, when trying to post back or going to the next page, the pager control is shifting down. In order to fix Grid height and width according to the page height and width, i have implemented bellow java script in page load. But unfortunately after post back it is not working.
var grid, gridHeight;
gridHeight = document.documentElement.offsetHeight - 130;
grid = $find('<%= GridControl1.FindControl("RadGrid4").ClientID %>');
if(grid !== null){
contentPane.set_height(document.documentElement.offsetHeight - 90);
grid.get_element().style.height = gridHeight+ "px";
contentSplitter.repaint();
grid.repaint();
}
else{
contentPane.set_height(document.documentElement.offsetHeight - 75);
}
Kindly suggest, how to fix Grid height in post back so that pager control should not shift down or disappear.
Thanks in advance.
Dipak

Hi,
We are currently evaluating the use of radgrids inside a radwizard to create a wizard that needs to collect validated data during entry in tables and that needs to send the collected info to a process at the last page of the wizard (classic behavior).
The idea seems mainstream but the use of grids and grids inside a wizard is not so easy.
Here is some problems we are facing:
1)We use fully client side radgrids: their initial data is populated by passing them empty lists of objects as a DataSource.
Rows can then be added manually using a button which triggers a 'fireCommand("InitInsert", "")'.
The users can batch edit the cells.
Can your please provide a working exemple of a RadGrid properly set up to be used fully client side and of the proper way to get its client values?
2)We tried setting ClientDataKeyNames to get the RadGrids data more easily: manually created rows with InitInsert, even when data has been entered manually, always provide empty values using getDataKeyValue("xxx") on the row.
Which is understandable as no data is actually bound.
How to properly get data from a RadGrid which is used this way?
As for now, we get the cells with js and search them for values. :(
3)Rows can also be added programmatically. Rows containGridTemplateColumns with DropDownList EditItemTemplate: How to programmatically set a RadDropDownList value in a client side RadGrid?
<telerik:GridTemplateColumn UniqueName="UserLanguage" SortExpression="UserLanguage" HeaderText="UserLanguage" DataField="UserLanguage" ShowFilterIcon="false"
EditFormColumnIndex="4" ColumnEditorID="CompanyListColumnEditor">
<HeaderStyle Width="50px" />
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "UserLanguage")%>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDropDownList RenderMode="Lightweight" ID="UserLangDD1" runat="server" Width="200px">
<Items>
<telerik:DropDownListItem Value="0" />
<telerik:DropDownListItem Value="F" Text="Français" />
<telerik:DropDownListItem Value="E" Text="English" />
</Items>
</telerik:RadDropDownList>
</EditItemTemplate>
</telerik:GridTemplateColumn>
I guess the problem resides in DataBinder.Eval() as no data is actually bound to the grid.
We tried setting UserLanguage with the display value ("Français" or "English") which does not work.
We tried to set UserLangDD1 with the Value (F or E) which does not work either.
4) The radWizard's Steps contain also other controls which are part of a validation group for each Step.
The validation works for these controls but does not apply to the fields of the rows which have been added to the Radgrids, despite these Column have as well Validators referencing the same ValidationGroup as the controls outside the Grids.
How to make a RadWizardStep apply RequiredFieldValidator on Grid Columns of RadGrids that it contains?
5) In a RadGrid, how not to block the user to getting out of a cell containing a Required control which has not yet been filled?
Currently, when a required control of a grid is not filled, it is forbidden to edit another control of these row, is there a workaround?
6) How to properly make a batch editable GridBoundColumn launch a popup (or equivalent) with a list of checkboxes as potential values and disallow users to actually write in this cell?
Any direction will be highly appreciated!
Hi,
if I have an excel-like filter with a few items selected as shown in the attached image, is there any way to programmatically unselect all the values from the listbox? I am using this code to explicitly clear the filter and it works for clearing the radgrid but it does not clear the filter listbox selections:
foreach (GridColumn column in grid.MasterTableView.Columns)
{
column.CurrentFilterFunction = GridKnownFunction.NoFilter;
column.CurrentFilterValue = string.Empty;
}
grid.MasgterTableView.FilterExpression = string.Empty;
grid.Rebind();

Hi there,
First let me show you my code first,
<!-- Page Content Body --> <div class="content mt-3"> <div class="animated fadeIn"> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-header"> <h4>Language Settings</h4> </div> <div class="card-body"> <div class="row form-group"> <asp:Panel CssClass="col-sm-12" ID="pnlMessage" runat="server"> <div class="alert alert-success alert-dismissible fade show" role="alert"> <span class="badge badge-pill" id="message_header"> <!-- add badge-[type] for changing notification style --> <asp:Label runat="server" ID="lbl_type"></asp:Label></span> <asp:Label runat="server" ID="lblMessage"></asp:Label> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> </asp:Panel> </div> <div class="row form-group"> <div class="col-md-6"> <div class="row"> <div class="col-md-5"> <asp:Label ID="label" AssociatedControlID="txt_languageName" Text="Enter language Name" runat="server" /> </div> <div class="col-md-7"> <telerik:RadTextBox runat="server" ID="txt_languageName" Skin="Glow" RenderMode="Lightweight" Width="100%"> <EnabledStyle BackColor="#FFFFFF" ForeColor="Black"></EnabledStyle> <FocusedStyle BackColor="Black" ForeColor="#FFFFFF"></FocusedStyle> <HoveredStyle BackColor="Black" ForeColor="#FFFFFF"></HoveredStyle> </telerik:RadTextBox> <small class="form-text text-muted hide_me">This is a help text</small> </div> </div> </div> <div class="col-md-6"> <div class="row"> <div class="col-md-5"> <asp:Label ID="label1" AssociatedControlID="txt_langCode" Text="Enter language Code" runat="server" /> </div> <div class="col-md-7"> <telerik:RadTextBox runat="server" ID="txt_langCode" Width="100%" Skin="Glow" RenderMode="Lightweight"> <EnabledStyle BackColor="#FFFFFF" ForeColor="Black"></EnabledStyle> <FocusedStyle BackColor="Black" ForeColor="#FFFFFF"></FocusedStyle> <HoveredStyle BackColor="Black" ForeColor="#FFFFFF"></HoveredStyle> </telerik:RadTextBox> <small class="form-text text-muted hide_me">This is a help text</small> </div> </div> </div> </div> <!-- second row --> <div class="row form-group"> <div class="col-md-6"> <div class="row"> <div class="col-md-5"> <asp:Label ID="label2" AssociatedControlID="txt_languageName" Text="Enter Culture Code" runat="server" /> </div> <div class="col-md-7"> <telerik:RadTextBox runat="server" ID="txt_culture_code" Skin="Glow" RenderMode="Lightweight" Width="100%"> <EnabledStyle BackColor="#FFFFFF" ForeColor="Black"></EnabledStyle> <FocusedStyle BackColor="Black" ForeColor="#FFFFFF"></FocusedStyle> <HoveredStyle BackColor="Black" ForeColor="#FFFFFF"></HoveredStyle> </telerik:RadTextBox> <small class="form-text text-muted hide_me">This is a help text</small> </div> </div> </div> <div class="col-md-6"> <div class="row"> <div class="col-md-5"> <asp:Label ID="label3" AssociatedControlID="txt_isoValue" Text="Enter ISO Code" runat="server" /> </div> <div class="col-md-7"> <telerik:RadTextBox runat="server" ID="txt_isoValue" Width="100%" Skin="Glow" RenderMode="Lightweight"> <EnabledStyle BackColor="#FFFFFF" ForeColor="Black"></EnabledStyle> <FocusedStyle BackColor="Black" ForeColor="#FFFFFF"></FocusedStyle> <HoveredStyle BackColor="Black" ForeColor="#FFFFFF"></HoveredStyle> </telerik:RadTextBox> <small class="form-text text-muted hide_me">This is a help text</small> </div> </div> </div> </div> <!-- third row --> <div class="row form-group"> <div class="col-md-12 headerClass"> <div class="btn-group"> <asp:Button runat="server" ID="btnSave" Text="Save" Width="53%" OnClick="btnSave_OnClick" CssClass="w3-btn" /> <asp:Button runat="server" ID="btnSearch" Text="Search" Width="53%" OnClick="btnSearch_OnClick" CssClass="w3-btn" /> </div> </div> </div> <!-- show hide radgrid --> <div class="row form-group"> <div class="col-md-12"> <telerik:RadGrid runat="server" ID="radGridLanguage" AutoGenerateColumns="False" BorderStyle="None" AllowPaging="True" AllowSorting="True" OnItemCommand="radGridLanguage_ItemCommand" PageSize="10" RenderMode="Lightweight" Skin="Glow" Style="margin-top: 1%; width: 98%; font-size: 13px"> <MasterTableView AllowFilteringByColumn="True" NoMasterRecordsText="No language data found" Height="10px" BackColor="#272c33" FilterItemStyle-BorderColor="white"> <Columns> <telerik:GridBoundColumn DataField="lang_name" FilterControlAltText="Filter column column" HeaderText="Language Name" UniqueName="column" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="culture_name" FilterControlAltText="Filter column1 column" HeaderText="Culture Name" UniqueName="column1" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="culture_code" FilterControlAltText="Filter column2 column" HeaderText="Culture Code" UniqueName="column2" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="iso_639x_value" FilterControlAltText="Filter column3 column" HeaderText="ISO Value" UniqueName="column3" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="Action" AllowFiltering="false"> <ItemTemplate> <asp:Label ID="lblLangAutoId" Text='<%#Eval("autoid") %>' runat="server" Visible="false"></asp:Label> <asp:ImageButton ID="imgBtnDelLanguage" runat="server" Width="20px" ImageUrl="~/Images/delete.png" OnClick="imgBtnDelLanguage_OnClick" OnClientClick="return confirm('want to delete?');" /> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> <PagerStyle Mode="NextPrevAndNumeric" /> <GroupingSettings CollapseAllTooltip="Collapse all groups" /> <HeaderStyle BackColor="#272c33" Font-Bold="True" BorderColor="white" /> </telerik:RadGrid> </div> </div> </div> </div> </div> </div> </div> </div> <!-- set ajaxify --> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="lp" ShowLoadingPanelForPostBackControls="True" UpdatePanelsRenderMode="Inline"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="btnSearch"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="radGridLanguage" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="lp" runat="server" Transparency="30" MinDisplayTime="300" EnableEmbeddedSkins="False"> <div class="loading"> <asp:Image ID="Image1" runat="server" ImageUrl="../../Images/loading-default.gif" AlternateText="loading"></asp:Image> </div> </telerik:RadAjaxLoadingPanel>
Now as you could see, I have four text box controls two button controls(Save,Search) and one grid and one panel control present in page.
Flow:
Now as mentioned previously two buttons are save and search.
protected void btnSave_OnClick(object sender, EventArgs e) { pnlMessage.Visible = true; _objBelAdministration.flag = "insert"; _objBelAdministration.strLanguageName = txt_languageName.Text.Trim(); _objBelAdministration.strCultureName = txt_langCode.Text.Trim(); _objBelAdministration.strCultureCode = txt_culture_code.Text.Trim(); _objBelAdministration.strIsoValue = txt_isoValue.Text.Trim(); if ((_objBlAdministration.InsertLanguageInfo(_objBelAdministration)) > 0) { lbl_type.Text = "Sucess"; lblMessage.Text = "Sucessfully inserted into database"; ScriptManager.RegisterStartupScript(this.Page, typeof(Type), "alert01", "addClassSucess();", true); } else { lbl_type.Text = "Failure!"; lblMessage.Text = "Problem while inserting into database"; ScriptManager.RegisterStartupScript(this.Page, typeof(Type), "alert012", "addClassDanger();", true); } GetLanguages(); } protected void imgBtnDelLanguage_OnClick(object sender, ImageClickEventArgs e) { pnlMessage.Visible = true; var button = (ImageButton)sender; var item = (GridDataItem)(button.NamingContainer); _objBelAdministration.flag = "delete"; _objBelAdministration.autoid = ((Label)(item.FindControl("lblLangAutoId"))).Text; if (_objBlAdministration.DeleteLanguageInfo(_objBelAdministration) > 0) { lbl_type.Text = "Sucess"; lblMessage.Text = "Deleted from database"; ScriptManager.RegisterStartupScript(this.Page, typeof(Type), "alert01", "addClassSucess();", true); } else { lbl_type.Text = "Error"; lblMessage.Text = "Error ocured when Deleting from database"; ScriptManager.RegisterStartupScript(this.Page, typeof(Type), "alert01", "addClassSucess();", true); } ResetControls(); GetLanguages(); } private void ResetControls() { txt_languageName.Text = ""; txt_langCode.Text = ""; txt_culture_code.Text = ""; txt_isoValue.Text = ""; }


I have a Grid control with one column of checkboxes. When I click on the checkbox in the header, select a value in a dropdown list, and then click a button two sql commands should run. However the sql commands are only executing for the top selected row in the Grid. I need it to execute for all checked rows. What's wrong with my code? When I click on the checkbox in the header the checkboxes on each row within the visible Grid are selected as expected.
Grid Markup:
<telerik:RadGrid ID="rgUnassnd" runat="server" DataSourceID="sdsRgUnassnd" AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" ShowGroupPanel="True" Skin="Default" AllowMultiRowSelection="true"> <ClientSettings AllowDragToGroup="True" AllowColumnsReorder="True" ReorderColumnsOnClient="True"> <Selecting AllowRowSelect="true" /> </ClientSettings> <MasterTableView DataSourceID="sdsRgUnassnd" DataKeyNames="assnmtIdPk" CommandItemDisplay="Top"> <CommandItemSettings ShowRefreshButton="true" ShowAddNewRecordButton="false" /> <Columns> <telerik:GridTemplateColumn UniqueName="CheckTemp"> <ItemTemplate> <asp:CheckBox ID="chkI" runat="server" /> </ItemTemplate> <HeaderTemplate> <asp:CheckBox ID="chkH" runat="server" AutoPostBack="true" OnCheckedChanged="chkH_CheckedChanged"/> </HeaderTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="assnmtIdPk" ReadOnly="True" HeaderText="assnmtIdPk" SortExpression="assnmtIdPk" UniqueName="assnmtIdPk" DataType="System.Int32" FilterControlAltText="Filter assnmtIdPk column"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="clmNo" HeaderText="Claim" SortExpression="clmNo" UniqueName="clmNo" FilterControlAltText="Filter clmNo column" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="assCrtdDt" ReadOnly="true" HeaderText="Date Received" SortExpression="assCrtdDt" UniqueName="assnmtCrtdDt" DataType="System.DateTime" FilterControlAltText="Filter assnmtCrtdDt column" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="clientNm" HeaderText="Client" SortExpression="clientNm" UniqueName="clientNm" FilterControlAltText="Filter clientNm column" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="carr" HeaderText="Carrier" SortExpression="carr" UniqueName="carr" FilterControlAltText="Filter carr column" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="riskAddCity" HeaderText="Risk City" SortExpression="riskAddCity" UniqueName="riskAddCity" FilterControlAltText="Filter riskAddCity column" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="provNm" HeaderText="Province" SortExpression="provNm" UniqueName="provNm" FilterControlAltText="Filter provNm column" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="riskZip" HeaderText="Zip Code" SortExpression="riskZip" UniqueName="riskZip" FilterControlAltText="Filter riskZip column" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true"></telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid>
Here's the code behind:
protected void assignUsers_Click(object sender, EventArgs e) { string tascnxn = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; GridHeaderItem hItem = rgUnassnd.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem; if (hItem != null) { foreach (GridDataItem item in rgUnassnd.MasterTableView.Items) { CheckBox ChkChange = item.FindControl("chkI") as CheckBox; if (ChkChange.Checked) { string assidpk = item.GetDataKeyValue("assnmtIdPk").ToString(); using (SqlConnection tasconn = new SqlConnection(tascnxn)) { SqlCommand repAssnmtCmd = new SqlCommand("INSERT INTO repAssnmts (raCrtdBy, raCrtdDt, assnmtIdFk, repId) VALUES (LTRIM(RTRIM(@raCrtdBy)), LTRIM(RTRIM(@raCrtdDt)), LTRIM(RTRIM(@assnmtIdFk)), LTRIM(RTRIM(@repId)))", tasconn); { repAssnmtCmd.Parameters.AddWithValue("@assnmtIdFk", assidpk); //need to get the id of the checked row repAssnmtCmd.Parameters.AddWithValue("@raCrtdBy", HttpContext.Current.User.Identity.GetUserId()); repAssnmtCmd.Parameters.AddWithValue("@raCrtdDt", DateTime.Now.ToString()); repAssnmtCmd.Parameters.AddWithValue("@repId", userList.SelectedValue); tasconn.Open(); repAssnmtCmd.ExecuteNonQuery(); } SqlCommand assnmtStatCmd = new SqlCommand("INSERT INTO assnmtStats (asCrtdBy, asCrtdDt, assnmtIdFk, aStatId) VALUES (LTRIM(RTRIM(@asCrtdBy)), LTRIM(RTRIM(@asCrtdDt)), LTRIM(RTRIM(@assnmtIdFk)), LTRIM(RTRIM(@aStatId)))", tasconn); { assnmtStatCmd.Parameters.AddWithValue("@assnmtIdFk", assidpk); //need to get the id of the checked row assnmtStatCmd.Parameters.AddWithValue("@asCrtdBy", HttpContext.Current.User.Identity.GetUserId()); assnmtStatCmd.Parameters.AddWithValue("@asCrtdDt", DateTime.Now.ToString()); assnmtStatCmd.Parameters.AddWithValue("@aStatId", 2); assnmtStatCmd.ExecuteNonQuery(); tasconn.Close(); if (IsPostBack) { lblBtnAssignUsers.ForeColor = System.Drawing.ColorTranslator.FromHtml("#0AA10A"); lblBtnAssignUsers.Text = "The file(s) were successfully assigned."; Response.Redirect(Request.RawUrl); } else { lblBtnAssignUsers.ForeColor = System.Drawing.ColorTranslator.FromHtml("#CA2823"); lblBtnAssignUsers.Text = "The assignment(s) failed. Please try again."; } } } } } } }
Here's the CheckChanged code:
protected void chkH_CheckedChanged(object sender, EventArgs e) { foreach (GridDataItem item in rgUnassnd.MasterTableView.Items) { CheckBox chkbx = (CheckBox)item["CheckTemp"].FindControl("chkI"); chkbx.Checked = !chkbx.Checked; } }
Hello-
All checklist options get selected if I check, "Select All" but they are cleared after I click, "Filter". All grid data is displayed properly. However, I would expect all checklist options to remain selected if I open the filter menu again. Is this working properly? Thanks!
