RadDatePicker date = new RadDatePicker(); date.EnableTyping = false; date.ShowPopupOnFocus = true;
protected void btnGenerate_Click(object sender, EventArgs e)
{
PopulateGrid();
}
protected void PopulateGrid()
{
GridPlaceHolder.Controls.Clear();
RadGrid GridReport = new RadGrid();
GridReport.GroupingSettings.CaseSensitive =
false;
GridReport.ID =
"GridReport";
GridReport.Skin =
"Gray";
GridReport.EnableViewState =
false;
GridReport.MasterTableView.EnableColumnsViewState =
false;
GridReport.Width =
Unit.Pixel(1413);
GridReport.Height =
Unit.Pixel(550);
GridReport.AllowPaging =
true;
GridReport.AllowSorting =
true;
GridReport.PageSize = 10;
GridReport.MasterTableView.AllowCustomPaging =
true;
GridReport.AutoGenerateColumns =
false;
GridReport.AllowFilteringByColumn =
false;
GridReport.EnableLinqExpressions =
false;
GridReport.GridLines =
GridLines.None;
GridReport.NeedDataSource +=
new GridNeedDataSourceEventHandler(this.GridReport_NeedDataSource);
GridReport.PageIndexChanged +=
new GridPageChangedEventHandler(this.GridReport_PageIndexChanged);
GridReport.PagerStyle.Mode =
GridPagerMode.NextPrevNumericAndAdvanced;
GridReport.ClientSettings.Scrolling.AllowScroll =
true;
GridReport.ClientSettings.Scrolling.UseStaticHeaders =
true;
GridReport.ClientSettings.Resizing.AllowColumnResize =
true;
GridReport.ClientSettings.Resizing.EnableRealTimeResize =
true;
GridReport.MasterTableView.AllowSorting =
true;
GridReport.MasterTableView.AllowNaturalSort =
false;
GridReport.MasterTableView.HierarchyLoadMode =
GridChildLoadMode.ServerOnDemand;
GridReport.ClientSettings.AllowExpandCollapse =
true;
GridReport.MasterTableView.TableLayout =
GridTableLayout.Fixed;
GridReport.MasterTableView.Width =
Unit.Pixel(1413);
GridReport.FilterMenu.EnableAjaxSkinRendering =
true;
GridReport.ClientSettings.AllowColumnsReorder =
false;
GridReport.ClientSettings.AllowDragToGroup =
false;
GridReport.ClientSettings.ReorderColumnsOnClient =
true;
GridReport.ClientSettings.Resizing.ResizeGridOnColumnResize =
true;
GridReport.ClientSettings.Resizing.ClipCellContentOnResize =
true;
GridReport.ClientSettings.EnableRowHoverStyle =
true;
GridReport.ClientSettings.ClientEvents.OnRowSelected =
"RowSelected";
GridReport.ClientSettings.Selecting.AllowRowSelect =
true;
LoadReport(GridReport);
GridPlaceHolder.Controls.Add(GridReport);
}
private void LoadReport(RadGrid GridReport)
{
string reportName = "Report_Operations";
switch (reportName )
{
case "Report_Operations":
GridReport.MasterTableView.DataKeyNames =
new string[] { "OperationID" };
GridReport = BLL.BO.Reports.
Operations.GenerateReportColumns(ref GridReport);
break;
}
private void GridReport_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
//do something
GridReport.DataSource = dt;}
void GridReport_PageIndexChanged(object source, GridPageChangedEventArgs e)
{
// DO SOMETHING, HERE THE BREAKPOINT NEVER HITS!
}
Thanks for your help!
How do I access a GridTemplateColumn in the Grid row that was clicked?
With the getDataKeyValue() method I can get the value of GridBoundColumns after defining the columns using the ClientDataKeyNames property of the MasterTableView.
But how can I get the value of GridTemplateColumns?
<
telerik:RadGrid ID="gridTestGrid" runat="server" AllowMultiRowEdit="True"
OnNeedDataSource
="gridTestGrid_DataSource"
OnItemDataBound
="gridTestGrid_ItemDataBound" OnPreRender="gridTestGrid_PreRender" OnItemCreated="gridTestGrid_ItemCreated" OnItemCommand="gridTestGrid_ItemCommand"
AutoGenerateColumns
="False" GridLines="Horizontal">
<
MasterTableView AutoGenerateColumns="False" CommandItemDisplay="TopAndBottom" DataKeyNames="TestGridID">
<
CommandItemTemplate>
<
asp:Button ID="btnUpdate" runat="server" Text="Update Changes" />
</
CommandItemTemplate>
<
RowIndicatorColumn>
<
HeaderStyle Width="20px"></HeaderStyle>
</
RowIndicatorColumn>
<
ExpandCollapseColumn>
<
HeaderStyle Width="20px"></HeaderStyle>
</
ExpandCollapseColumn>
<
Columns>
......Some Other Columns .....
<
telerik:GridTemplateColumn HeaderText="Facility" Visible="false"
UniqueName
="rcbColumn">
<
ItemTemplate>
</
ItemTemplate>
<
EditItemTemplate>
<
telerik:RadComboBox ID="rcbFacility" runat="server" AllowCustomText="true" MarkFirstMatch="true" Width="300px" AppendDataBoundItems="true"></telerik:RadComboBox>     Send to IT?: <asp:CheckBox ID="ckBox" runat="server" Checked="false" />
</
EditItemTemplate>
</
telerik:GridTemplateColumn>
</
Columns>
</
MasterTableView>
protected
void gridTestGrid_ItemCreated(object source, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item is GridEditableItem && e.Item.IsInEditMode)
{
LinkButton
updateButton = (LinkButton)e.Item.FindControl("UpdateButton");
updateButton.Text =
"";
LinkButton
cancelButton = (LinkButton)e.Item.FindControl("CancelButton");
cancelButton.Text =
"";
}
}
protected
void gridTestGrid_PreRender(object source, EventArgs e)
{
foreach
(GridDataItem item in gridTestGrid.Items)
{
item.Edit =
true;
gridTestGrid.Rebind();
}
}
protected
void gridTestGrid_ItemCommand(object source, GridCommandEventArgs e)
{
Hashtable
newValues = new Hashtable();
foreach
(GridEditableItem editedItem in gridTestGrid.Items)
{
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
RadComboBox
combo = ((RadComboBox)editedItem["rcbColumn"].FindControl("rcbFacility"));
if
(combo != null)
{
string
selected = combo.SelectedItem.ToString();
}
}
}
.grid { height:auto !important; height:100%; min-height:250px; }But this not helped
.pagerPosition { position:absolute; bottom:10px; text-align:right; }This helps some what like the pager moved to the bottom but some spacing difference in different browser.