<telerik:RadGrid ID="rdtgContactUs" runat="server" AutoGenerateColumns="False" GridLines="None" |
AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" OnInit="rdtgContactUs_Init" |
OnNeedDataSource="rdtgContactUs_NeedDataSource" OnItemCommand="rdtgContactUs_ItemCommand" |
AllowMultiRowSelection="true" PageSize="25" PagerStyle-Mode="NextPrevAndNumeric" |
> |
<PagerStyle AlwaysVisible="True" Position="TopAndBottom" /> |
<ClientSettings> |
<Selecting AllowRowSelect="true" /> |
</ClientSettings> |
<GroupingSettings CaseSensitive="false" /> |
<MasterTableView DataKeyNames="ContactID,Replied"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<HeaderStyle Font-Bold="true" /> |
<Columns> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
I have a Telerik RadGrid within a .ascx (user control) that requires a *_NeedDataSource method to populate the grid's DataSource.
The same user control is doing some user authentication, simply checking HttpContext.Current.User.Identity.IsAuthenticated and doing a Response.Redirect(url, false) if it is false.
I'm seeing exceptions being raised on our live system due to the *_NeedDataSource method being called when the user is not logged in, this seems to be possible because I pass false as the value of the endResponse parameter to Response.Redirect. The original author coded it this way as I assume he was going on the guidance of the community:
I've been trying to work out a way that I can reliably prevent execution of *_NeedDataSource without reverting to an endResponse value of true.
I can think of some ways which involve flag setting and checking but that seems inelegant and subsequent developers could forget to implement the same pattern. I've also tried implementing a base control type to derive from which overrides OnPreRender (or whatever), similar to the response from Spongeboy to this question: ASP.NET Redirect and End Page but I cannot work out the method to override that will prevent execution of *_NeedDataSource.
Can anyone recommend an approach that would work in this situation and wouldn't require too much cognitive overhead?
Apologies, egregiously copied from http://stackoverflow.com/questions/41483271/avoid-grid-needdatasource-call-if-response-redirect-is-called-previously
Hello,
Now I am looking into this demo
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx
When I click "Add new record" button, I can see that the delete button in the inserted row is available.
But I cannot see the delete button with my own code.
<%@ Page Language="c#" CodeFile="Default.aspx.cs" Inherits="Telerik.GridExamplesCSharp.DataEditing.BatchEditing.Default" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<
html
xmlns
=
'http://www.w3.org/1999/xhtml'
>
<
head
runat
=
"server"
>
<
title
>Telerik ASP.NET Example</
title
>
<
link
href
=
"styles.css"
rel
=
"stylesheet"
/>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
/>
<
telerik:RadSkinManager
ID
=
"RadSkinManager1"
runat
=
"server"
ShowChooser
=
"true"
/>
<
div
id
=
"demo"
class
=
"demo-container no-bg"
>
<
telerik:RadGrid
ID
=
"RadGrid1"
GridLines
=
"None"
runat
=
"server"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
PageSize
=
"10"
AllowAutomaticUpdates
=
"True"
AllowPaging
=
"True"
AutoGenerateColumns
=
"False"
OnNeedDataSource
=
"ApiGrid_NeedDataSource"
>
<
MasterTableView
CommandItemDisplay
=
"TopAndBottom"
DataKeyNames
=
"ProductID"
HorizontalAlign
=
"NotSet"
EditMode
=
"Batch"
AutoGenerateColumns
=
"False"
>
<
BatchEditingSettings
EditType
=
"Cell"
/>
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"ProductID"
SortOrder
=
"Descending"
/>
</
SortExpressions
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ProductName"
HeaderStyle-Width
=
"210px"
HeaderText
=
"ProductName"
SortExpression
=
"ProductName"
UniqueName
=
"ProductName"
>
<
ColumnValidationSettings
EnableRequiredFieldValidation
=
"true"
>
<
RequiredFieldValidator
ForeColor
=
"Red"
Text
=
"*This field is required"
Display
=
"Dynamic"
>
</
RequiredFieldValidator
>
</
ColumnValidationSettings
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
ConfirmText
=
"Delete this product?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Delete"
HeaderText
=
"Delete"
HeaderStyle-Width
=
"50px"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumn"
>
</
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
AllowKeyboardNavigation
=
"true"
></
ClientSettings
>
</
telerik:RadGrid
>
</
div
>
</
form
>
</
body
>
</
html
>
using System;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
namespace Telerik.GridExamplesCSharp.DataEditing.BatchEditing
{
public class Data
{
public string ProductName { get; set; }
public string ProductID { get; set; }
}
public partial class Default : System.Web.UI.Page
{
/// <
summary
>
/// Process need data source event from ApiGrid.
/// </
summary
>
/// <
param
name
=
"sender"
></
param
>
/// <
param
name
=
"e"
></
param
>
protected void ApiGrid_NeedDataSource( object sender, GridNeedDataSourceEventArgs e )
{
RadGrid1.DataSource = new Data[]
{
new Data()
{
ProductName = "AAA",
ProductID ="111"
},
new Data()
{
ProductName = "AAA",
ProductID ="222"
}
};
}
}
}
Could you please give me some advice?
Thanks.
I have a radGrid on a page which periodically refreshes the data from the server.
The grid has filter and sorting enabled.
Is it possible to keep the sort order/filter option when the page refreshes itself? As currently it all reset on auto-refresh.
<
telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="grdAdminList" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
if (e.Argument == "Rebind")
{
grdAdminList.Rebind();
}
function
refreshGrid()
{
GetRadWindow().BrowserWindow.refreshGrid();
}
Main page function:
function refreshGrid()
{
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
}
Hi, I am currently using RadGrid version 5.1.1.0 in my project. Though I have set certain settings i.e.
AllowColumnResize="true"
ResizeGridOnColumnResize="true"
ClipCellContentOnResize="true"
EnableRealTimeResize="true
to True. The grid doesn't allow me to resize the columns in IE 11, however, the same renders properly in Google Chrome.
Can you guys let me know if this is a known issue with RadGrid control.
Hi, we have an issues with rad grid resizing and this issue is only in IE11 in chrome its working perfectly.
This is the grid client settings and mastertable view code:
<
telerik:RadGrid
ID
=
"grdInvoiceList"
CssClass
=
""
Skin
=
"MetroTouch"
Width
=
"100%"
runat
=
"server"
AutoGenerateColumns
=
"false"
PagerStyle-HorizontalAlign
=
"Right"
AllowCustomPaging
=
"true"
AllowPaging
=
"true"
AllowFilteringByColumn
=
"true"
AllowSorting
=
"true"
EnableHeaderContextMenu
=
"true"
OnNeedDataSource
=
"grdInvoiceList_NeedDataSource"
OnItemDataBound
=
"grdInvoiceList_ItemBound"
OnItemCreated
=
"grdInvoiceList_ItemCreated"
EnableLinqExpressions
=
"false"
OnPreRender
=
"grdInvoiceList_PreRender"
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
ExportSettings
FileName
=
"Invoice_Details"
OpenInNewWindow
=
"true"
ExportOnlyData
=
"true"
IgnorePaging
=
"true"
>
</
ExportSettings
>
<
ClientSettings
Resizing-AllowColumnResize
=
"true"
AllowAutoScrollOnDragDrop
=
"true"
Resizing-AllowResizeToFit
=
"true"
Resizing-EnableRealTimeResize
=
"true"
>
<
Scrolling
AllowScroll
=
"True"
SaveScrollPosition
=
"true"
></
Scrolling
>
<
Selecting
AllowRowSelect
=
"true"
/>
<
ClientEvents
OnColumnResized
=
"ColumnResized"
/>
<
ClientEvents
OnColumnShown
=
"ColumnShown"
/>
<
ClientEvents
OnColumnHidden
=
"ColumnHidden"
/>
<
ClientEvents
OnRowContextMenu
=
"RowContextMenu"
/>
</
ClientSettings
>
<
HeaderStyle
Width
=
"150px"
></
HeaderStyle
>
<
MasterTableView
Width
=
"100%"
AutoGenerateColumns
=
"false"
EditMode
=
"InPlace"
AllowFilteringByColumn
=
"True"
TableLayout
=
"Auto"
>
1, check image "IE-grid-1.png " once we land on the page we can see the scroll bar and we can scroll left to right without issues in IE.
2, now check "IE-grid-2.png" i just resized the grid header now the scroll bar disappeared. i will not get the scroll bar unless i reload the page.
is there a solution to resolve this issue? we are using telerik 2014.1.403.40.