or
<telerik:GridTemplateColumn UniqueName="TemplateDeleteColumn">
<ItemTemplate>
<asp:HyperLink ID="DeleteLink" runat="server" Text="Delete"></asp:HyperLink>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:RadListBox ID="RadListBox1" Width="200px" Height="300px"
SelectionMode="Multiple" runat="server"></telerik:RadListBox>
<telerik:RadListBox ID="RadListBox2" Width="300px" Height="300px" runat="server">
</telerik:RadListBox>void button1_Click(object sender, EventArgs e)
{
foreach (RadListBoxItem selectedItem in RadListBox1.SelectedItems)
{
RadListBox2.Items.Add(new RadListBoxItem(selectedItem.Text));
}
}<telerik:RadGrid ID="rgLog" runat="server" ShowGroupPanel="False" AllowPaging="true" ItemStyle-BackColor="#ffe394" BackColor="White" Visible="true" Height="200" PageSize="25" Skin="Office2010Black" AllowSorting="true" AutoGenerateColumns="false" BorderWidth="0px" Width="1000" AllowCustomPaging="True" OnNeedDataSource="rgLog_NeedDataSource" OnItemDataBound="rgLog_ItemDataBound"> <AlternatingItemStyle BackColor="White" /> <ClientSettings AllowColumnHide="True" AllowColumnsReorder="True" AllowGroupExpandCollapse="True" ReorderColumnsOnClient="True" AllowDragToGroup="False"> <Scrolling AllowScroll="False" UseStaticHeaders="True" /> <Resizing AllowColumnResize="true" AllowRowResize="true" /> </ClientSettings> <GroupingSettings ShowUnGroupButton="False" /> <PagerStyle AlwaysVisible="true" Position="TopAndBottom" /> <MasterTableView TableLayout="Fixed" CommandItemDisplay="Top"> <NoRecordsTemplate> <br /> No Records matched this search.<br /> <br /> </NoRecordsTemplate> <CommandItemSettings ShowExportToWordButton="false" ShowExportToExcelButton="false" ShowExportToCsvButton="true" ShowExportToPdfButton="false" ShowAddNewRecordButton="false" /> <Columns> <telerik:GridTemplateColumn HeaderText="View Events" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <a href="<%# GetURL( Eval("Number")) %>"> <img src='images/1258747021_old-edit-find.png' alt="View Detail" border="0" /> </a> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="View Report" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <a href="<%# GetChartURL( Eval("Number")) %>"> <img src='images/1259005159_pie_chart_search.png' width="24" alt="View Detail" border="0" /> </a> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="Number" Visible="false" /> <telerik:GridBoundColumn DataField="Percent %" HeaderText="% of Total" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:p}" /> <telerik:GridBoundColumn DataField="COUNT" HeaderText="Event Count" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:###,###,###}" /> </Columns> </MasterTableView> </telerik:RadGrid><Telerik:DDLGridColumn UniqueName="ProductType" Query="select Name AS ProductType, ID AS ProductTypeID From ProductTypes WHERE RetailerID={1}" GetRetailerIDFromSession="True" DataField="ProductType" DataValueField="ProductTypeID" HeaderText="ProductType" SortExpression="ProductType"> <ItemTemplate> <%# Eval("ProductType")%> </ItemTemplate></Telerik:DDLGridColumn>public class DDLGridColumn: GridTemplateColumn { protected override void SetupFilterControls(System.Web.UI.WebControls.TableCell cell) { RadComboBox rcBox = new RadComboBox(); rcBox.ID = this.UniqueName + "_rcbox"; rcBox.AutoPostBack = true; rcBox.DataTextField = this.DataField; rcBox.DataValueField = DataValueField ?? this.DataField; rcBox.SelectedIndexChanged += rcBox_SelectedIndexChanged; rcBox.Width = FilterControlWidth; string query = query = string.Format(this.Query, this.DataField); DataTable table = DBLayer.GetDataTable(query, CommandType.Text); DataRow row = table.NewRow(); table.Rows.InsertAt(row, 0); rcBox.DataSource = table; cell.Controls.Add(rcBox); } private void rcBox_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e) { ((GridFilteringItem)(((RadComboBox)sender).Parent.Parent)).FireCommandEvent("Filter", new Pair()); } protected override void SetCurrentFilterValueToControl(TableCell cell) { if (!(this.CurrentFilterValue == "")) { ((RadComboBox)cell.Controls[0]).Items.FindItemByValue(this.CurrentFilterValue).Selected = true; } } protected override string GetCurrentFilterValueFromControl(TableCell cell) { string currentValue = ((RadComboBox)cell.Controls[0]).SelectedItem.Value; this.CurrentFilterFunction = (currentValue != "") ? GridKnownFunction.EqualTo : GridKnownFunction.NoFilter; return currentValue; } }
Html.Telerik().ComboBox().Name("StyleImage").ClientEvents(events => events.OnChange("onChange") )here is js code
function onChange(e) { alert(e.value);} here is grid onedit
function Grid_onEdit(e) { var styleImage = $('#StyleImage').data('tComboBox'); $.getJSON(appUrl("Controller/Action"), { styleId: styleValue }, function (data) { styleImage.dataBind(data.value); styleImage.value(e.dataItem['DefaultImage']); } ); } } Here is controller code
public JsonResult Action(string styleId) { List<string> images=new List<string>(); return Json(new { success = true, value = images }, JsonRequestBehavior.AllowGet); }this is how I am seeing rendered code for combo box
<div class="t-animation-container" style="width: 150px; height: 214px; position: absolute; z-index: 10002; top: 382.817px; left: 599.733px; display: none;">
I figured out how to set defaults for the multiple check boxes.
Here is my example:
DataTable tableMonths = new DataTable();tableMonths.Columns.Add("name", typeof(int));tableMonths.Columns.Add("value", typeof(string));tableMonths.Rows.Add(12, "12");tableMonths.Rows.Add(24, "24");tableMonths.Rows.Add(36, "36");tableMonths.Rows.Add(48, "48");tableMonths.Rows.Add(60, "60");tableMonths.Rows.Add(72, "72");RadComboBoxMonths.DataSource = tableMonths;RadComboBoxMonths.DataTextField = "name";RadComboBoxMonths.DataValueField = "value";RadComboBoxMonths.DataBind();// preselect these terms by defaultRadComboBoxMonths.SelectedValue = "12";RadComboBoxItem twelveMonths = (RadComboBoxItem)RadComboBoxMonths.SelectedItem;twelveMonths.Checked = true;RadComboBoxMonths.SelectedValue = "24";RadComboBoxItem twentyFourMonths = (RadComboBoxItem)RadComboBoxMonths.SelectedItem;twentyFourMonths.Checked = true;RadComboBoxMonths.SelectedValue = "36";RadComboBoxItem thritySixMonths = (RadComboBoxItem)RadComboBoxMonths.SelectedItem;thritySixMonths.Checked = true;<%@ Page Title="" Language="VB" MasterPageFile="~/AdminPanel/Admin.master" AutoEventWireup="false" CodeFile="pager_test.aspx.vb" Inherits="AdminPanel_franchise_pager_test" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadGrid2"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid2"></telerik:AjaxUpdatedControl> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <br /> <hr /> <div style="border: 5px solid #eaf2fd; width: 95%;"> <telerik:RadGrid ID="RadGrid2" DataSourceID="SqlDataSource2" AllowPaging="True" PageSize="5" runat="server" GridLines="None" Width="100%" AllowSorting="True" CellSpacing="0"> <PagerStyle Mode="NextPrevAndNumeric" EnableSEOPaging="False"></PagerStyle> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemStyle HorizontalAlign="Center"></ItemStyle> <AlternatingItemStyle HorizontalAlign="Center"></AlternatingItemStyle> <MasterTableView CommandItemDisplay="Top"> <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings><RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn><ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column" Created="True"></ExpandCollapseColumn><EditFormSettings><EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn></EditFormSettings><PagerStyle PageSizeControlType="RadComboBox"></PagerStyle> <CommandItemTemplate> <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> </CommandItemTemplate> </MasterTableView> <FilterMenu EnableImageSprites="False"></FilterMenu> </telerik:RadGrid> </div> <br /> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SQL %>" SelectCommand="SELECT [a], [b], [c], [d], [e] FROM [franchises] WHERE ([xyz] LIKE @xyz)"> <SelectParameters> <asp:Parameter Name="xyz" Type="String" DefaultValue="%" /> </SelectParameters> </asp:SqlDataSource> </asp:Content>
Protected Sub RadGrid2_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid2.ItemCreated
If TypeOf e.Item Is GridCommandItem Then
Dim commandItem As GridCommandItem = CType(e.Item, GridCommandItem)
Dim container As PlaceHolder = commandItem.FindControl("PlaceHolder1")
Dim i As Integer
For i = 65 To 65 + 25
Dim linkButton1 As New LinkButton
Dim lc As New LiteralControl(" ")
linkButton1.Text = "" + ChrW(i)
linkButton1.CommandName = "alpha"
linkButton1.CommandArgument = "" + ChrW(i)
container.Controls.Add(linkButton1)
container.Controls.Add(lc)
Next i
Dim lcLast As New LiteralControl(" ")
container.Controls.Add(lcLast)
Dim linkButtonAll As New LinkButton
linkButtonAll.Text = "All"
linkButtonAll.CommandName = "NoFilter"
container.Controls.Add(linkButtonAll)
End If
End Sub
Protected Sub RadGrid2_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid2.ItemCommand
Dim value As String = Nothing
Select Case e.CommandName
Case ("alpha")
value = String.Format("{0}%", e.CommandArgument)
Exit Select
Case ("NoFilter")
value = "%"
Exit Select
End Select
SqlDataSource2.SelectParameters("xyz").DefaultValue = value
RadGrid2.Rebind()
End Sub