or
public class FilteringByDropDownBoundColumn : GridBoundColumn { private object listDataSource = null; private Unit filterControlWidth = Unit.Percentage(90); // default private string filterTextField = "Text"; private string filterValueField = "Value"; public string FilterTextField { get { return filterTextField; } set { filterTextField = value; } } public string FilterValueField { get { return filterValueField; } set { filterValueField = value; } } protected override void SetupFilterControls(TableCell cell) { base.SetupFilterControls(cell); Control oldFilter = cell.Controls[0]; cell.Controls.RemoveAt(0); DropDownList list = new DropDownList(); list.ID = "list" + DataField; list.AutoPostBack = true; list.SelectedIndexChanged += new EventHandler(list_SelectedIndexChanged); list.DataTextField = FilterTextField; list.DataValueField = FilterValueField; list.DataSource = ListDataSource; list.Width = FilterControlWidth; list.Height = Unit.Pixel(20); list.EnableViewState = true; list.Attributes.Add("style", "font-size:.9em"); cell.Controls.AddAt(0, list); cell.Controls.RemoveAt(1); } void list_SelectedIndexChanged(object sender, EventArgs e) { GridFilteringItem filterItem = (sender as DropDownList).NamingContainer as GridFilteringItem; filterItem.FireCommandEvent("Filter", new Pair()); } public new Unit FilterControlWidth { get { return (Unit)filterControlWidth; } set { filterControlWidth = value; } } public object ListDataSource { get { return listDataSource; } set { listDataSource = value; } } protected override void SetCurrentFilterValueToControl(TableCell cell) { base.SetCurrentFilterValueToControl(cell); DropDownList list = (DropDownList)cell.Controls[0]; if (CurrentFilterValue != string.Empty) { list.SelectedValue = CurrentFilterValue; } } protected override string GetCurrentFilterValueFromControl(TableCell cell) { DropDownList list = (DropDownList)cell.Controls[0]; return list.SelectedValue; } protected override string GetFilterDataField() { return FilterValueField; } protected override void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); } private void InitializeComponent() { SetupTabs(); SetupFilters(NeedsActionAccountsGrid); } private void DataBindGrid(string view, RadGrid grid) { if (grid != null && !string.IsNullOrEmpty(view)) { QueueViewType viewType = (QueueViewType)(Enum.Parse(typeof(QueueViewType), view)); Rep rep = LoggedInUser; DateTime? LastModifiedBeginDate = null; DateTime? LastModifiedEndDate = null; DateCriteria.SetDate(ref LastModifiedBeginDate, ref LastModifiedEndDate, GetLastModifiedDateCriteria(grid)); List<AccountQueueRecord> datasource = AccountQueueLogic.GetAccountsQueueItems(rep, viewType, LastModifiedBeginDate, LastModifiedEndDate, GetRegistrationTypeID(grid), grid.PageSize, grid.CurrentPageIndex); grid.DataSource = datasource; grid.DataBind(); } } private string GetRegistrationTypeID(RadGrid grid) { string RegistrationTypeID = null; FilteringByDropDownBoundColumn col = grid.Columns.FindByDataFieldSafe("Registration") as FilteringByDropDownBoundColumn; if (col != null && col.CurrentFilterValue != "All") RegistrationTypeID = col.CurrentFilterValue; return RegistrationTypeID; } private void SetupFilters(RadGrid grid) { if (grid == null) return; LookupTypeService lookupService = new LookupTypeService(); FilteringByDropDownBoundColumn col = grid.Columns.FindByDataFieldSafe("Registration") as FilteringByDropDownBoundColumn; if (col != null) { List<RegistrationType> list = new List<RegistrationType>(); list.Add(new RegistrationType() { Display = "All", Code = "All" }); list.AddRange(lookupService.GetAllEnabled(LookupTypeEnum.RegistrationType).Cast<RegistrationType>().ToList()); col.ListDataSource = list; col.FilterTextField = "Display"; col.FilterValueField = "Code"; } } protected void GridAccountQueue_ItemCommand(object source, GridCommandEventArgs e) { if (e.CommandName == RadGrid.FilterCommandName) { e.Canceled = true; RadGrid grid = (RadGrid)source; grid.MasterTableView.FilterExpression = ""; // clear this since we're providing a filtered datasource string viewID = ""; string gridID = grid.ID; switch (gridID) { case "NeedsActionAccountsGrid": case "NeedsActionProposalsGrid": viewID = NeedsActionTabs.SelectedTab.SelectedTab.Value; // go to second level of tabs break; } DataBindGrid(viewID, grid); } } <telerik:RadGrid ID="NeedsActionAccountsGrid" runat="server" OnItemCommand = "GridAccountQueue_ItemCommand"
OnSortCommand="GridAccountQueue_SortCommand"OnPageSizeChanged="GridAccountQueue_PageSizeChanged" OnPageIndexChanged="GridAccountQueue_PageIndexChanged" AutoGenerateColumns="false" PageSize="10" ShowStatusBar="true" AllowSorting="true" AllowPaging="true" AllowCustomPaging="true" Skin="Simple" AllowFilteringByColumn="true"> <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"/> <StatusBarSettings LoadingText="Loading..." /> <MasterTableView HeaderStyle-BackColor="Gray" HeaderStyle-ForeColor="White" EnableColumnsViewState="true" TableLayout="Auto"> <SortExpressions> <telerik:GridSortExpression FieldName="LastModified" SortOrder="Descending" /> </SortExpressions> <Columns> <telerik:GridHyperLinkColumn AllowFiltering="false" HeaderText="AC ID" DataTextField="AccountID" DataNavigateUrlFields="AccountID" DataNavigateUrlFormatString="/Administratin/AccountSummary.aspx?id={0}" HeaderStyle-Width="5%" ItemStyle-Width="5%" ItemStyle-CssClass="AccountLink" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></telerik:GridHyperLinkColumn> <custom:FilteringByDropDownBoundColumn HeaderText="Rep code" DataField="RepCode" HeaderStyle-Width="6%" ItemStyle-Width="6%" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></custom:FilteringByDropDownBoundColumn> <custom:FilteringByDropDownBoundColumn HeaderText="Registration" HeaderAbbr="Reg." DataField="Registration" HeaderStyle-Width="10%" ItemStyle-Width="10%"></custom:FilteringByDropDownBoundColumn> <custom:FilteringByDropDownBoundColumn HeaderText="Platform" DataField="Platform" HeaderStyle-Width="12%" ItemStyle-Width="12%"></custom:FilteringByDropDownBoundColumn> <custom:FilteringByDropDownBoundColumn HeaderText="Product Type" HeaderAbbr="Prod. Type" DataField="ProductType" HeaderStyle-Width="12%" ItemStyle-Width="12%"></custom:FilteringByDropDownBoundColumn> <telerik:GridBoundColumn HeaderText="Account Holders" HeaderAbbr="Acct. Holders" DataField="AccountHolders" FilterControlWidth="90%" AutoPostBackOnFilter="false"></telerik:GridBoundColumn> <custom:FilteringByDropDownBoundColumn HeaderText="Last Modified" HeaderAbbr="Last Mod." DataField="LastModified" DataFormatString="{0:M/dd/yyyy h:mm tt}" HeaderStyle-Width="13%" ItemStyle-Width="13%"></custom:FilteringByDropDownBoundColumn> <telerik:GridBoundColumn AllowFiltering="false" HeaderText="Status" DataField="Status" HeaderStyle-Width="15%" ItemStyle-Width="15%" ></telerik:GridBoundColumn> <telerik:GridButtonColumn ButtonType="ImageButton" HeaderText="Notes" HeaderStyle-Width="4%" ItemStyle-Width="4%" ImageUrl="../Images/grid/icon_attachment.gif" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></telerik:GridButtonColumn> <telerik:GridButtonColumn ButtonType="ImageButton" HeaderText="Docs" HeaderStyle-Width="4%" ItemStyle-Width="4%" ImageUrl="../Images/grid/icon_attachment.gif" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></telerik:GridButtonColumn> </Columns> </MasterTableView> <ClientSettings> <Resizing AllowColumnResize="true" /> </ClientSettings> </telerik:RadGrid> Greetings,
How i can get SelectedItemIndex in listview to client-side?
Regards,
public class RadFilterBooleanDropDownEditor : RadFilterDataFieldEditor { protected override void CopySettings(RadFilterDataFieldEditor baseEditor) { base.CopySettings(baseEditor); var editor = baseEditor as RadFilterBooleanDropDownEditor; if (editor != null) { //DataSourceID = editor.DataSourceID; //DataTextField = editor.DataTextField; //DataValueField = editor.DataValueField; } } public override System.Collections.ArrayList ExtractValues() { ArrayList list = new ArrayList(); list.Add(int.Parse(_combo.SelectedValue)); return list; } public override void InitializeEditor(System.Web.UI.Control container) { _combo = new RadComboBox(); _combo.ID = "MyCombo"; _combo.Width = System.Web.UI.WebControls.Unit.Pixel(48); _combo.Items.Add(new RadComboBoxItem("True","1")); _combo.Items.Add(new RadComboBoxItem("False","0")); //container.Controls[1].Visible = false; container.Controls.Add(_combo); } public override void SetEditorValues(System.Collections.ArrayList values) { if (values != null && values.Count > 0) { if (values[0] == null) return; var item = _combo.FindItemByValue(values[0].ToString()); if (item != null) item.Selected = true; } } public string DataTextField { get { return (string)ViewState["DataTextField"] ?? string.Empty; } set { ViewState["DataTextField"] = value; } } public string DataValueField { get { return (string)ViewState["DataValueField"] ?? string.Empty; } set { ViewState["DataValueField"] = value; } } public string DataSourceID { get { return (string)ViewState["DataSourceID"] ?? string.Empty; } set { ViewState["DataSourceID"] = value; } } private RadComboBox _combo; }Object reference not set to an instance of an object.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] Telerik.Web.UI.RadFilterDataFieldEditor.CreateEditorFrom(RadFilterDataFieldEditor baseEditor) +9 Telerik.Web.UI.RadFilterSingleExpressionItem.SetupFunctionInterface(Control container) +55 Telerik.Web.UI.RadFilterExpressionItem.CreateFunctionalInterface() +89 Telerik.Web.UI.RadFilterExpressionItem.InitializeItem() +24 Telerik.Web.UI.RadFilter.CreateFilterItems() +284 Telerik.Web.UI.RadFilter.CreateControlHierarchy() +34 Telerik.Web.UI.RadFilter.CreateChildControls() +90 System.Web.UI.Control.EnsureChildControls() +102 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +20 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Page.FindControl(String id) +38 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +287 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +878var tabstrip = $find("<%=RadTabStrip1.ClientID %>"); var tab = tabstrip.findTabByText("Statistics"); var amount = tab.findControl("txt_amount"); "txt_amount" is the ID of a TextBox in a tab named "statistics." Any suggestions would be greatly appreciated.
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" OnTabClick="RadTabStrip1_TabClick"> <Tabs> <telerik:RadTab Text="Tab1" Selected="true"/> <telerik:RadTab Text="Tab2" /> <telerik:RadTab Text="Tab2" /> </Tabs></telerik:RadTabStrip><telerik:RadMultiPage ID="RadMultiPage1" runat="server"> <telerik:RadPageView ID="RadPageView1" runat="server" Width="100%" Selected="true">xxx</telerik:RadPageView> <telerik:RadPageView ID="RadPageView2" runat="server" Width="100%">yyy</telerik:RadPageView> <telerik:RadPageView ID="RadPageView3" runat="server" Width="100%">zzz</telerik:RadPageView></telerik:RadMultiPage>
<asp:Button ID="btnOk" runat="server" Text="OK" onclick="btnOk_Click" /> public string CurrentPageViewID{ get { if (ViewState["CurrentPageViewID"] != null) return (string)ViewState["CurrentPageViewID"]; else return "RadPageView1"; } set { ViewState["CurrentPageViewID"] = value; }}protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e){ //update current tab CurrentPageViewID = e.Tab.PageView.ID;}protected void btnOk_Click(object sender, EventArgs e){ Response.Write("Current Tab PageView ID is " + CurrentPageViewID);}