Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
178 views
Hi,
    I am trying to use the declarative client binding method to bind radgrid using webservice. I am having trouble passing the custom argument. When i use the standard 4 arguments everything works. Once i add my custom argument it stops working. i don't get any error, grid doesn't even call the webservice.

    Here is what i have in ASPX...

<telerik:RadGrid ID="RadGrid1" AllowSorting="true" AllowPaging="true" AllowFilteringByColumn="true" 
            AutoGenerateColumns="false" runat="server">  
            <MasterTableView > 
                <Columns> 
                    <telerik:GridBoundColumn DataField="DocID" HeaderText="DocID" /> 
                    <telerik:GridBoundColumn DataField="Title" HeaderText="Title" /> 
                </Columns> 
            </MasterTableView> 
            <PagerStyle Mode="NumericPages" /> 
            <ClientSettings> 
                <DataBinding Location="http://localhost/iProWS/GetGridData.asmx" 
                    SelectMethod="GetDataAndCount" EnableCaching="true"  /> 
                    <ClientEvents OnDataBinding="RadGrid1_DataBinding" /> 
            </ClientSettings> 
        </telerik:RadGrid> 

Here is the java script
function RadGrid1_DataBinding(sender, args)  
        {  
             var methodArguments = args.get_methodArguments();  
                
             methodArguments.WhereCond = "myValue";  
             args.set_methodArguments(methodArguments);  
       }  
 
i tried to use as listed in the demo, but no luck
function RadGrid1_DataBinding(sender, args)  
        {  
            var myMethodArguments = new Object();  
            myMethodArguments.WhereCond = "myValue";  
            args.set_methodArguments(myMethodArguments);  
       }  
 
             

Here is the Webservice
 <WebMethod(EnableSession:=True)> _  
Public Function GetDataAndCount(ByVal startRowIndex As IntegerByVal maximumRows As IntegerByVal sortExpression As List(Of GridSortExpression), ByVal filterExpression As List(Of GridFilterExpression), ByVal WhereCond As StringAs Dictionary(Of StringObject)  
        Dim data As New Dictionary(Of StringObject)()  
 
        data.Add("Data", GetData(startRowIndex, maximumRows, sortExpression, filterExpression, WhereCond))  
        data.Add("Count"DirectCast(Session("Count"), Integer))  
 
        Return data  
    End Function 

I greatly appreciate if someone can figure out what i am doing wrong.  I looked this post which shows the same as demo but for some reason it's not working for me.

Thanks,

Yavor
Telerik team
 answered on 22 May 2009
1 answer
117 views
I'm working on a project where I need to save the clients address details along with map references.

I had in mind a web page with a button on it (i'm using the Grid control with Editforms to allow editing).
When the user clicks the button 'map references', a rad window pops up with the Microsoft virtual earth map showing.
The user then locates the address and clicks the map to get the latitude and longitude values.
The user clicks the 'submit' button of the rad window to close it and to transfer the values to the address form, filling in the longitude and latitude text boxes.
The values are then save to a db.

I would be grateful for comments on the best way forward.

Kind regards
Andrew
Ivo
Telerik team
 answered on 22 May 2009
1 answer
252 views

I want to export RadGrid styles to PDF.  I have a radgrid in a normal .aspx page, and I use a usercontrol to export the radgrid to pdf format.  I have read the tips and tricks article, but am still unable to get exporting styles to PDF to work.

Here is the radgrid in a normal aspx page:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> 
<%@ Register TagPrefix="uc1" TagName="Export" Src="~/Controls/ctrlExportReport.ascx" %> 
 
<!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> 
    <form id="form1" runat="server">  
    <div> 
        <asp:ScriptManager ID="sm1" runat="server"></asp:ScriptManager> 
        <table style="width: 100%">  
            <tr> 
                <td> 
                    <telerik:radwindowmanager id="rwm" runat="server" modal="true" reloadonshow="true" visibletitlebar="True" behavior="close, move" visiblestatusbar="false">  
                    </telerik:radwindowmanager> 
                    <telerik:RadAjaxLoadingPanel id="rdpInterventions" runat="server" cssclass="DataGrid" style="text-align: center; background-color: White; width: 100%">  
                        <class="header">  
                            Loading interventions due within the selected date range</p> 
                        <br /> 
                        <p> 
                            <img id="Img1" alt="loading..." runat="server" src="~/Images/LoadingProgressBar.gif" /></p>  
                    </telerik:RadAjaxLoadingPanel> 
                    <telerik:radajaxpanel id="rap" runat="server" enableajax="true" LoadingPanelID="rdpInterventions">  
                    <Telerik:radgrid id="rg" runat="server" autogeneratecolumns="true" width="100%" Skin="" > 
                    <mastertableview allowsorting="true" cssclass="DataGrid" gridlines="horizontal" showfooter="true" width="100%">  
                    <HeaderStyle forecolor="blue" BackColor="Black" /> 
                            <DetailTables> 
                                <telerik:GridTableView DataMember="Detail" DataKeyNames="SourceID" Width="95%">  
                                    <ParentTableRelation> 
                                        <telerik:GridRelationFields MasterKeyField="SourceID" DetailKeyField="SourceID" /> 
                                    </ParentTableRelation> 
                                </telerik:GridTableView> 
                            </DetailTables> 
                        </MasterTableView> 
                    </telerik:RadGrid> 
                    </telerik:radajaxpanel> 
                </td> 
            </tr> 
            <tr> 
                <td style="height: 25px">  
                    <uc1:Export ID="ctrlExport1" runat="server" ControlName="rg" /> 
                </td> 
            </tr> 
        </table> 
    </div> 
    </form> 
</body> 
</html> 
 

Here is the code for the usercontrol:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ctrlExportReport.ascx.vb" Inherits="ctrlExportReport" %> 
 
<asp:ImageButton ID="btnExportToExcel" runat="server" AlternateText="Export to Excel" ImageUrl="~/Images/Export2Excel.gif" ToolTip="Export to Excel" /> 
&nbsp;&nbsp;&nbsp;&nbsp;  
<asp:ImageButton ID="btnExportToPDF" runat="server" AlternateText="Export to PDF" ImageUrl="~/Images/Export2Pdf.gif" ToolTip="Export to PDF" /> 
<input id="hdnHidePDF" runat="Server" type="hidden" /> 
 

And here is the code-behind for the user control:
''' <summary>  
''' Export a RadGrid to either Excel or PDF.  
''' </summary>  
Partial Class ctrlExportReport  
    Inherits System.Web.UI.UserControl
#Region " Declarations "  
 
    'The ID of the RadGrid displaying the report.  
    Private strControlName As String = String.Empty
    
#End Region 'Declarations  
 
#Region " Properties " 
 
    'The ID of the RadGrid displaying the report.  
    Public Property ControlName() As String 
        Get 
            If String.IsNullOrEmpty(strControlName) = False Then 
                Return strControlName  
            End If 
 
            Return String.Empty  
        End Get 
        Set(ByVal value As String)  
            strControlName = value  
        End Set 
    End Property 
 
    'Boolean whether or not to display the PDF button.  
    Public Property HidePDF() As Boolean 
        Get 
            If String.IsNullOrEmpty(hdnHidePDF.Value) Then 
                Return False 
            Else 
                Return hdnHidePDF.Value  
            End If 
        End Get 
        Set(ByVal value As Boolean)  
            hdnHidePDF.Value = value  
        End Set 
    End Property 
 
    'Boolean whether or not to display the page title.  
    Public Property IncludePageTitle() As Boolean 
        Get 
            If ViewState.Item("IncludePageTitle"Is Nothing Then 
                Return False 
            Else 
                Return ViewState.Item("IncludePageTitle")  
            End If 
        End Get 
        Set(ByVal value As Boolean)  
            ViewState.Item("IncludePageTitle") = value  
        End Set 
    End Property 
 
    'The BaseFileName constant with the current date appended.  
    Private ReadOnly Property FileName() As String 
        Get 
            Return String.Format("{0}-{1}-{2}", Now.Year.ToString(), PadDatePart(Now.Month), PadDatePart(Now.Day)).Insert(0, AppFileName)  
        End Get 
    End Property 
 
    Public Property PageTitle() As String 
        Get 
            If ViewState.Item("PageTitle"Is Nothing Then 
                Return ConfigurationManager.AppSettings("DefaultPageTitle")  
            Else 
                Return ViewState.Item("PageTitle").ToString()  
            End If 
        End Get 
        Set(ByVal value As String)  
            ViewState.Item("PageTitle") = value  
        End Set 
    End Property 
 
    Private ReadOnly Property AppFileName() As String 
        Get 
            If Not String.IsNullOrEmpty(ConfigurationManager.AppSettings("AppFileName")) Then 
                Return ConfigurationManager.AppSettings("AppFileName").ToString  
            Else 
                Return "GIC" 
            End If 
        End Get 
    End Property 
 
    Private ReadOnly Property Report() As RadGrid  
        Get 
            If String.IsNullOrEmpty(Me.ControlName) = False Then 
                Dim objControl As Control = Parent.FindControl(Me.ControlName)  
 
                If objControl IsNot Nothing Then 
                    Try 
                        Return DirectCast(objControl, RadGrid)  
                    Catch ex As Exception  
                        'objControl could not be cast to a RadGrid. Free  
                        'resources and return Nothing.  
                        objControl = Nothing 
                    End Try 
                End If 
            End If 
 
            Return Nothing 
        End Get 
    End Property
#End Region 'Properties  
 
#Region " Events " 
 
    Protected Sub btnExportToExcel_Click(ByVal sender As ObjectByVal e As System.Web.UI.ImageClickEventArgs) Handles btnExportToExcel.Click  
        If Me.Report IsNot Nothing Then 
            Me.ConfigureExportSettings()  
 
            Report.MasterTableView.ExportToExcel()  
        End If 
    End Sub 
 
    Protected Sub btnExportToPDF_Click(ByVal sender As ObjectByVal e As System.Web.UI.ImageClickEventArgs) Handles btnExportToPDF.Click  
        If Me.Report IsNot Nothing Then 
            '-- 1) Expand and rebind the grid --  
            Me.Report.MasterTableView.HierarchyDefaultExpanded = True 
            Me.Report.Rebind()  
            '-- 2) Setup the export settings --  
            Me.ConfigureExportSettings(True)  
            '-- 3) Export the report --  
            With Report  
                .Page.Response.ClearHeaders()  
                .Page.Response.Cache.SetCacheability(HttpCacheability.Private)  
                .MasterTableView.ExportToPdf()  
            End With 
        End If 
    End Sub 
 
    '  Check to see if the HidePDF property has been set - if so, hide that button.  
    Protected Sub Page_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.PreRender  
        If HidePDF Then 
            Me.btnExportToPDF.Visible = False 
        End If 
    End Sub
#End Region 'Events  
 
#Region " Methods " 
 
    'These settings are shared by both Excel and PDF.  
    Private Sub ConfigureExportSettings(Optional ByVal bPdf As Boolean = False)  
        '-- 1) Set the global report export settings --  
        With Report.ExportSettings  
            .OpenInNewWindow = True 'Makes GUI cleaner.  
            .FileName = Me.FileName  
            .ExportOnlyData = True 'Header will be included.  
            .IgnorePaging = True 'All Records - setting this to true means if the grid is collapsed by default, the PDF will not show   
            ' the detail items even if the user expands the parent items manually. Conversely, if the grid is expanded by default, the   
            ' pdf will show the detail items even if the user collapses them.  
        End With 
        '-- 2) Set the msater table font and styles --  
        With Report.MasterTableView.Font  
            .Name = "Arial" 
            .Size = New FontUnit(9, UnitType.Point)  
        End With 
        With Report.MasterTableView.HeaderStyle.Font  
            .Name = "Arial" 
            .Size = New FontUnit(9, UnitType.Point)  
        End With 
        '-- 3) Hide any of the command items (if applicable) --  
        For Each commandItem As GridItem In Report.MasterTableView.GetItems(GridItemType.CommandItem)  
            commandItem.Visible = False 
        Next 
        '-- 4) Set the Pdf Export Settings if doing the Pdf export --  
        If bPdf Then 
            With Report.ExportSettings.Pdf  
                If IncludePageTitle Then 
                    .PageTitle = PageTitle  
                Else 
                    .PageTitle = "" 
                End If 
                .PageTopMargin = New Unit(0.7, UnitType.Inch)  
                .FontType = Telerik.Web.Apoc.Render.Pdf.FontType.Embed  
                .PageBottomMargin = New Unit(0.4, UnitType.Inch)  
                .PageLeftMargin = .PageBottomMargin  
                .PageRightMargin = .PageBottomMargin  
            End With 
 
            Dim headerItem As GridHeaderItem  
            For Each headerItem In Report.MasterTableView.GetItems(GridItemType.Header)  
                headerItem.Style("font-size") = "16pt" 
                headerItem.Style("color") = "red" 
                headerItem.Style("background-color") = "yellow" 
                headerItem.Style("height") = "50px" 
                headerItem.Style("vertical-align") = "bottom" 
 
                For Each cell As TableCell In headerItem.Cells  
                    cell.Style("text-align") = "left" 
                    cell.Style("font-weight") = "bold" 
                    cell.Style("border-color") = "red" 
                Next 
            Next 
        End If 
    End Sub 
 
    Private Function PadDatePart( _  
        ByVal intDatePart As IntegerAs String 
 
        Dim strDatePart As String = intDatePart.ToString()  
 
        If strDatePart.Length = 1 Then 
            strDatePart = "0" & strDatePart  
        End If 
 
        Return strDatePart  
    End Function
#End Region 'Methods  
 
End Class 'Partial "ctrlExportReport"  
 


Can you help me figure out what I am doing wrong?

Thanks!
Jill
Le
Top achievements
Rank 1
 answered on 22 May 2009
2 answers
220 views
Hello,

I'm using a hierarchical radgrid control which has three levels (a master and two detail tables). Each row has a template column that contains a checkbox. What I want to do is to check all checkboxes in the hierarchy when checkbox in the inner row is checked, and I would like to achieve this in client code. 

The only thing I've been able to get is catching the click event on the checkbox and finding the row where the checkbos control is:

     function CkeckBox_Click(e) {      
      if (e.target) {
        gridRow = e.target.parentNode.parentNode;
      }
      else {
        gridRow = e.srcElement.parentNode.parentNode;
      }

Could you please help me?
Thanks in advance.
Yavor
Telerik team
 answered on 22 May 2009
1 answer
78 views
After clicking edit, the data in the label does not show on RadGrid.
Select SelectIndex?

 DropDownList list = item.FindControl("List1") as DropDownList;
           list.DataSource = Country_values;
           list.DataBind();

           list.SelectedIndex = ?????; <<<Here

Pls



Shinu
Top achievements
Rank 2
 answered on 22 May 2009
0 answers
101 views
Hi telerik team,

i have a doubt relative to rad menu item focus. i heard if menu placed in master and click of any item page will get post back so its difficult to maintain item selected . so i approached  in another way where in default.aspx  page Menu and footer will be there and content will be in IFRAME , through javascript on click of item content iframe alone gets post back ,not entire page below is the code which used
<telerik:RadMenuItem Text="Defendant" onclick="return Redirect(this.href);" NavigateUrl="Parties/Defendant.aspx">  
                                        </telerik:RadMenuItem> 
 
 <script language="javascript" type="text/javascript">  
        function Redirect( url)  
        {  
            document.getElementById("Frame").srcurl;  
            return false;  
        }  
    </script> 

i know that telerik provides Breadcrumb ,i tried work's fine but due to constraints i want menu should get highlighted alone.
Ex:bateswhite.com

Any help appreciable.

Thanks & Regards
G.Sudheer kumar
sudheer
Top achievements
Rank 2
 asked on 22 May 2009
1 answer
119 views

Hi

I'm using Q3    2008 release

I have been trying to emulate the hierarchy with template demo. I am using the Northwind database. My master table contains customers in the database. 

 I have been able to create a NestedViewTemplate that contains a hidden label containing the primary key for the parent row. I then use this row as a control parameter in an sql data source to populate a radgrid nested inside the NestedViewTemplate with orders for the customer ( i know i could use a standard master detail table for this but because of a layout demands I need to investigate this NestedViewTemplate). I have been able to populate the nested radgrid declaratively but I would like to know how to populate it programmatically. I have played around in the detail table data bind event to try and find some way to access the controls in the NestedViewTemplate but to no avail.

 

I have pasted the code below for the declarative 'version' which works ok

 

Many thanks in advace

<

 

asp:ScriptManager ID="ScriptManager1" runat="server">

 

 

 

 

 

</asp:ScriptManager>

 

 

 

 

 

<telerik:RadGrid ID="RadGrid1" runat="server" >

 

 

 

 

 

<MasterTableView DataKeyNames="CustomerID" >

 

 

 

 

 

<ExpandCollapseColumn Visible="True">

 

 

 

 

 

</ExpandCollapseColumn>

 

 

 

 

 

<NestedViewTemplate>

 

 

 

 

 

 

<telerik:RadTabStrip runat="server" ID="TabStrip1" MultiPageID="Multipage1"

 

 

 

 

 

SelectedIndex="0">

 

 

 

 

 

<Tabs>

 

 

 

 

 

<telerik:RadTab runat="server" Text="Orders" PageViewID="PageView1">

 

 

 

 

 

</telerik:RadTab>

 

 

 

 

 

<telerik:RadTab runat="server" Text="Contact Information" PageViewID="PageView2">

 

 

 

 

 

</telerik:RadTab>

 

 

 

 

 

<telerik:RadTab runat="server" Text="Statistics Chart" PageViewID="PageView3">

 

 

 

 

 

</telerik:RadTab>

 

 

 

 

 

</Tabs>

 

 

 

 

 

</telerik:RadTabStrip>

 

 

 

 

 

<telerik:RadMultiPage runat="server" ID="Multipage1" RenderSelectedPageOnly="false">

 

 

 

 

 

<telerik:RadPageView runat="server" ID="PageView1">

 

 

 

 

 

<asp:Label ID="Label1" Font-Bold="true" Font-Italic="true" Text='<%# Eval("CustomerID") %>'

 

 

 

 

 

runat="server" />

 

 

 

 

PageView 1

 

 

 

 

<telerik:RadGrid runat="server" ID="RadGrid2">

 

 

 

 

 

<MasterTableView DataSourceID="SqlDataSource2">

 

 

 

 

 

<Columns>

 

 

 

 

 

<telerik:GridBoundColumn DataField="OrderDate"></telerik:GridBoundColumn>

 

 

 

 

 

</Columns>

 

 

 

 

 

</MasterTableView>

 

 

 

 

 

</telerik:RadGrid>

 

 

 

 

 

 

<asp:SqlDataSource ID="SqlDataSource2" ConnectionString="Data Source=OSCAR\SQLExpress;Initial Catalog=Northwind;Integrated Security=true;"

 

 

 

 

 

ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM Orders Where CustomerID = @CustomerID"

 

 

 

 

 

runat="server">

 

 

 

 

 

 

<SelectParameters>

 

 

 

 

 

<asp:ControlParameter ControlID="Label1" PropertyName="Text" Type="String" Name="CustomerID" />

 

 

 

 

 

</SelectParameters>

 

 

 

 

 

 

</asp:SqlDataSource>

 

 

 

 

 

</telerik:RadPageView>

 

 

 

 

 

</telerik:RadMultiPage>

 

 

 

 

 

</NestedViewTemplate>

 

 

 

 

 

 

</MasterTableView>

 

 

 

 

 

</telerik:RadGrid>

 

 

 

 

 

 

Princy
Top achievements
Rank 2
 answered on 22 May 2009
3 answers
357 views
Hello.  Trying to implement a radcombobox in a radmenu in a radgrid header.  I have everything displaying correctly, however,
I cannot get the radgrid to filter at all.  Additionally, I am trying to filter by multiple columns and I don't think that is currently
possible with the way it is written now.  I have to have this working by Friday, so any help is GREATLY appreciated.  I took this
template from another post that incuded a textbox for the filter.  Thank you.  Code below.

ASPX Page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="Rad" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:Label ID="l" runat="server" />
      <Rad:RadMenu ID="TabMenu" runat="server" OnItemClick="TabMenu_ItemClick" style="position:absolute;left:0px;top:103px;z-index:0;">
      <Items>
      <Rad:RadMenuItem Text="Choice 1">
      </Rad:RadMenuItem>
      <Rad:RadMenuItem Text="Choice 2">

      </Rad:RadMenuItem>
      </Items>
      </Rad:RadMenu>

      <Rad:RadGrid ID="RadGrid1" runat="server" Skin="Default" Gridlines="None" AllowSorting="True" EnableLinqExpressions="False"
      AutoGenerateColumns="True" style="position:absolute;top:129px;left:0px;" OnItemCreated="RG1_ItemCreated">
      <PagerStyle Mode="NextPrevAndNumeric" />
      <MasterTableView AutoGenerateColumns="True" TableLayout="Fixed" />
      <ClientSettings ReorderColumnsOnClient="True" AllowColumnsReorder="True">
      <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" />
      </ClientSettings>
      </Rad:RadGrid>
     
      <asp:SqlDataSource ID="SqlDS1" runat="server"
      ConnectionString=..........................."
      SelectCommand="SELECT * FROM [Table1]" />
      <asp:SqlDataSource ID="SqlDS2" runat="server"
      ConnectionString=".........................."
      SelectCommand="SELECT * FROM [Table2]" />
     
    </form>
</body>
</html>

Code Behind

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;

public partial class _Default : System.Web.UI.Page
{
    static string tester;
    static RadGrid TestGrid;
    static string expression;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void TabMenu_ItemClick(object sender, RadMenuEventArgs e)
    {
        l.Text  = expression;
        switch (e.Item.Text)
        {
            case "Choice 1":
                RadGrid1.DataSourceID = "SqlDS1";
                break;
            case "Choice 2":
                RadGrid1.DataSourceID = "SqlDS2";
                break;

        }
    }
    protected void RG1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridHeaderItem)
        {
            foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns)
            {
                if (!column.Visible)
                    continue;

                ((GridHeaderItem)e.Item)[column.UniqueName].Controls.Clear();

                Label GridHeadLbl1 = new Label();
                GridHeadLbl1.Text = column.HeaderText;
                GridHeadLbl1.Style["float"] = "left";
                ((GridHeaderItem)e.Item)[column.UniqueName].Controls.Add(GridHeadLbl1);

                RadMenu RadMenu1 = new RadMenu();
                RadMenu1.Style["border"] = "0px";
                RadMenu1.Style["float"] = "right";
                RadMenu1.Style["margin-right"] = "10px";
                RadMenu1.Items.Add(new RadMenuItem(""));
                RadMenu1.Items[0].PostBack = false;

                RadMenuItem MenuItem1 = new RadMenuItem("Sort Asc");
                MenuItem1.Value = column.UniqueName;
                RadMenu1.Items[0].Items.Add(MenuItem1);

                RadMenuItem MenuItem2 = new RadMenuItem("Sort Des");
                MenuItem1.Value = column.UniqueName;
                RadMenu1.Items[0].Items.Add(MenuItem2);

                RadMenuItem MenuItem3 = new RadMenuItem("Filter");
                MenuItem1.Value = column.UniqueName;
                RadMenu1.Items[0].Items.Add(MenuItem3);

                RadMenuItem MenuSubItem1 = new RadMenuItem();
                tester = column.UniqueName;
                TestGrid = RadGrid1;
                MenuSubItem1.ItemTemplate = new MyTemplate();
                MenuSubItem1.Width = Unit.Pixel(150);
                MenuSubItem1.Value = column.UniqueName;
                MenuItem3.Items.Add(MenuSubItem1);

                ((GridHeaderItem)e.Item)[column.UniqueName].Controls.Add(RadMenu1);
            }
        }
    }

    public class MyTemplate : ITemplate
    {
        #region Itemplate Members

        RadComboBox Combo1;

        public void InstantiateIn(Control container)
        {
            Combo1 = new RadComboBox();
            Combo1.AutoPostBack = true;
            Combo1.AppendDataBoundItems = true;
            Combo1.DataSourceID = TestGrid.DataSourceID;
            Combo1.DataTextField = tester;
            Combo1.DataValueField = tester;
            Combo1.ItemDataBound += new RadComboBoxItemEventHandler(Combo1_ItemDataBound);
            Combo1.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(Combo1_SelectedIndexChanged);
          //  Combo1.SelectedValue = RadGrid1.OwnerTableView.GetColumn(tester).CurrentFilterValue;
            container.Controls.Add(Combo1);
        }

        public void Combo1_SelectedIndexChanged(object sender, EventArgs e)
        {
            RadMenuItem item = ((RadComboBox)sender).Parent as RadMenuItem;

            expression = "";

            RadGrid RadGrid1 = (RadGrid)item.Page.FindControl("RadGrid1");
            GridColumn column = RadGrid1.MasterTableView.GetColumnSafe(item.Value);

            if (column.DataType == typeof(string))
            {
                expression = String.Format(@"{0}.Contains(""{1}"")", item.Value, ((RadComboBox)sender).SelectedValue);
            }
            else
            {
                expression = String.Format("{0} == {1}", item.Value, ((RadComboBox)sender).SelectedValue);
            }
            RadGrid1.MasterTableView.FilterExpression = expression;

            RadGrid1.Rebind();
        }

        public void Combo1_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
        {
            if (Combo1.FindItemByText(e.Item.Text).ClientID != e.Item.ClientID)
            {
                e.Item.Visible = false;
            }
        }

        #endregion
    }
}

Yavor
Telerik team
 answered on 22 May 2009
4 answers
344 views

I am trying to leverage the extensive editing capability built into RadGrid to replace a GridView / custom pages (insert/update code).

My data is being sourced from multiple tables and I am using LINQ to retrieve the data.

There is a small snippet of code below, all joined an an "OrgID" field. The join works fine and the resulting data is in fact what I am looking for. However, when I apply the data source and bind it, RadGrid cannot seem to display the columns, auto-generated or otherwise.

It might be related to how I am concanting the data (select new {p,o}) and if that is the case, I need to know what the prefered format of the data is.

My goal is to create a system using rad grid where I can edit a record and have it update as many as 10 tables at once that are all joined together without having to write any update/insert code (or very little).

                var v = (from p in m_db.OrgLists  
                         join o in m_db.HostLocations on p.id equals o.OrgNameID  
                         select new {p, o});  
 
                // Get the data  
                rgOrgList.DataSource = v;  
 
                rgOrgList.DataBind(); 

Thanks in advance,

Jim
Nikolay Rusev
Telerik team
 answered on 22 May 2009
1 answer
169 views
Is there a property on the grid that will cause the update to occur when the user is editng a row and selects the Enter key?
Shinu
Top achievements
Rank 2
 answered on 22 May 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?