Hi,
I've got a page with one Placeholder on it and nothing else. I've added the RadScriptManager and the RadGrid using the code below and the Paging works ok but the sorting doesn't? No error is thrown. It shows the sorting icons in the column heading but does not actually do the sorting.
If I do exaclty the same using the Designer pages it all works fine. It's trying to do things programmatically that I can't get it to work.
default.aspx
==========
<%@ Page EnableEventValidation="false" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TelerikGridExample._Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<asp:PlaceHolder runat="server" ID="ph"></asp:PlaceHolder>
</body>
</html>
default.aspx.cs
==============
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace TelerikGridExample
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
HtmlForm f1 = new HtmlForm();
// script manager
Telerik.Web.UI.RadScriptManager sm = new Telerik.Web.UI.RadScriptManager();
sm.ID = "RadScriptManager1";
// data source
SqlDataSource ds = new SqlDataSource(@"Data Source=gbe-pc\express2008;Initial Catalog=Northwind;User ID=sa;Password=something", "SELECT categoryid, categoryname FROM [categories]");
ds.ID = "SqlDataSource1";
// rad grid
Telerik.Web.UI.RadGrid rg = new Telerik.Web.UI.RadGrid();
rg.ID = "RadGrid1";
rg.PageSize = 5;
rg.AllowPaging = true;
rg.AllowSorting = true;
rg.AutoGenerateColumns = false;
rg.GroupingEnabled = true;
rg.ClientSettings.AllowDragToGroup = true;
rg.EnableViewState = false;
// add some columns
Telerik.Web.UI.GridBoundColumn c1 = new Telerik.Web.UI.GridBoundColumn();
rg.MasterTableView.Columns.Add(c1);
c1.DataField = "categoryid";
c1.SortExpression = "categoryid";
c1.UniqueName = "categoryid";
c1.DataType = System.Type.GetType("System.Int32");
c1.HeaderText = "categoryid";
Telerik.Web.UI.GridBoundColumn c2 = new Telerik.Web.UI.GridBoundColumn();
rg.MasterTableView.Columns.Add(c2);
c2.DataField = "categoryname";
c2.SortExpression = "categoryname";
c2.UniqueName = "categoryname";
c2.DataType = System.Type.GetType("System.String");
c2.HeaderText = "categoryname";
rg.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(rg_NeedDataSource);
// add to controls to the ajax panel
f1.Controls.Add(sm);
f1.Controls.Add(ds);
f1.Controls.Add(rg);
ph.Controls.Add(f1);
}
void rg_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
Telerik.Web.UI.RadGrid myrg = (Telerik.Web.UI.RadGrid)Page.FindControl("RadGrid1");
myrg.DataSource = (SqlDataSource)Page.FindControl("SqlDataSource1");
}
}
}
Here is my code
protected void RadComboBoxLang_Load(object sender, EventArgs e)
{
String pRequest = pGetLang;
RadComboBox radComboBoxLang = sender as RadComboBox;
radComboBoxLang.SelectedValue = pRequest.ToUpper();
bool p_test = MvcBeaDAL.CookiesManager.SetGetCookie(radComboBoxLang.SelectedValue);
}
protected void RadGridLang_Load(object sender, EventArgs e)
{
String pRequest = GetLang();
pGetLang = pRequest;
RadGrid pRadGridLang = this.FindControl("RadGridLang") as RadGrid;
List<LanguageHost> radLang = new List<LanguageHost>();
radLang.Add( MvcBeaDAL.WebServiceBea.GetWebLanguageID(pRequest));
pRadGridLang.DataSource = radLang.ToList();
pRadGridLang.DataBind();
}
function SetUploadButtonEnabled(controlPanel, fileUploadId) {
var docTypesList = controlPanel.find("select");
var gotListVal = docTypesList.val() != "";
var fileUpload = $find(fileUploadId);
var gotFileVal = fileUpload.getUploadedFiles().length > 0;
var enable = gotListVal && gotFileVal;
if (enable) {
controlPanel.find(".GxButtonBlue").removeAttr("disabled");
}
else {
controlPanel.find(".GxButtonBlue").attr("disabled", true);
}
}
string script = "<
script
type=\"text/javascript\">"
+ "\n $(document).ready(function (){"
+ "\n $(document).on(\"change\", \"#" + this._DdDocumentTypes.ClientID + "\", function(event){"
+ "\n var docUploadControlPanel = $(this).closest(\"#" + this._DocUploadControlPanel.ClientID + "\");"
+ "\n SetUploadButtonEnabled(docUploadControlPanel, \"" + this._fiInput.ClientID + "\");"
+ "\n });"
+ "\n });"
+ "\n "
+ "</
script
>";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "DocumentAjaxUploadCtrlScript_" + this.ClientID, script);
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "DocumentAjaxUploadCtrlScript_" + this.ClientID, script, true);
Hi,
I have two questions here.
I am using a RADGRID and when ME.LOADComplete event is happening I run a procedure which will filter the RAD Grid - roughly about 200 rows by default from the SQL View, it then goes down to about 20 results. The query takes less than 0 seconds to run on SQL Management studio. It takes about 1-2 seconds to display the page and filter the view.
In a different window, I am returning a view which has about 17,000 rows in it and takes about 4 seconds to run in SQL Management Studio but then it takes about 14 seconds to display and filter the page. It takes about 8 seconds to load without being filtered. Both RADGRIDs has the data source set in the ASPX page but I was wondering is there not a more efficient way to filter it first and then if the user changes the filter, it will apply accordingly? The number of results would be about 400 or so. I was thinking I need to use OnNeedDataSource and filter directly from SQL instead of the programmatically way of
rgCompanyTickets.MasterTableView.FilterExpression = strFilter
rgCompanyTickets.Rebind()
My other issue is that, in the RADGRID I have added a new column so the user can check the box and when the user presses a button on the screen, it displays a RadWindow which says enter comment and click a button so that it can update the db. The issue I am facing is that when the page gets loaded from the first button click is that it is removing the state the checkboxes are in. So when I press the 2nd button, it doesn't know what rows I have selected before the post back. I believe the reason why it is doing this is due to me using the rebind statement during the filter process.
Do you know guys have any solutions or ideas about this?
<
telerik:GridTemplateColumn
UniqueName
=
"CheckBoxTemplateColumn"
AllowFiltering
=
"False"
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"CheckBox1"
runat
=
"server"
/>
</
ItemTemplate
>
<
HeaderTemplate
>
<
asp:CheckBox
ID
=
"headerChkbox"
runat
=
"server"
/>
</
HeaderTemplate
>
</
telerik:GridTemplateColumn
>
Thanks,
Alex
​<
telerik:RadTextBox
ID
=
"rtbTelefon"
MaxLength
=
"50"
Width
=
"220px"
EmptyMessage
=
"Telefon"
ToolTip
=
"Telefon"
runat
=
"server"
/><
telerik:RadTextBox
ID
=
"rtbEpost"
MaxLength
=
"50"
Width
=
"230px"
EmptyMessage
=
"E-postadress"
ToolTip
=
"E-postadress"
runat
=
"server"
/> <
asp:CustomValidatorid
=
"AtLeastOneContact"
ClientValidationFunction
=
"AtLeastOne_ClientValidate"
Display
=
"None"
ErrorMessage="Telefon <b>eller</
b
> e-post krävs!" SetFocusOnError="True"runat="server" />
function
AtLeastOne_ClientValidate(source, args) {
if
(document.getElementById(
"<%= rtbTelefon.ClientID %>"
).value ==
""
&&
document.getElementById(
"<%= rtbEpost.ClientID %>"
).value ==
""
) {
args.IsValid =
false
;
}
else
{
args.IsValid =
true
;
}
}