Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
2.0K+ views
Hi,

I am new to radcontrols. Started using this week.
My problem is I want to get the column value inside a row of a radgrid. I am using the cde bewlo

var mymultiplier = MasterTable.getCellByColumnUniqueName(dataItem, 'Multiplier');

Instead of getting the value of multiplier, I am getting the HTML. Please help.
Sabaratnam
Top achievements
Rank 1
 answered on 04 Dec 2012
2 answers
174 views
I have a rad grid that is AJAXified through a RadAjaxManager and I use a javascript function to stop the async request so I can export. This works perfectly in Chrome and Firefox. But does not seem to work in internet explorer. The page just refreshes. Any workarounds to this?

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <script type="text/javascript">
 
        Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initRequest);
        function initRequest(sender, args) {
            if (args.get_postBackElement().id.indexOf("btn_ExcelExport") != -1) {
                args.set_cancel(true);  //stop async request
                sender._form["__EVENTTARGET"].value = args.get_postBackElement().id.replace(/\_/g, "$");
                sender._form["__EVENTARGUMENT"].value = "";
                sender._form.submit();
                return;
            }
        }
      
    </script>
 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rg_Clients">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rg_Clients" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadGrid ID="rg_Clients" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
        ActiveItemStyle-BackColor="#004070" ActiveItemStyle-ForeColor="White" AllowSorting="True"
        CellSpacing="0" GridLines="Both" OnNeedDataSource="rg_Clients_NeedDataSource"
        Skin="WebBlue" OnItemCommand="rg_Clients_ItemCommand" AutoGenerateColumns="false"
        EnableLinqExpressions="false" HeaderStyle-Font-Bold="true" OnColumnCreating="rg_Clients_ColumnCreating"
        GroupingSettings-CaseSensitive="false" OnPreRender="rg_Clients_PreRender">
        <MasterTableView AutoGenerateColumns="false" AllowFilteringByColumn="True">
            <Columns>
                <telerik:GridTemplateColumn AllowFiltering="false" UniqueName="ClientID" HeaderStyle-Width="40px"
                    ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">
                    <HeaderTemplate>
                        <asp:ImageButton ID="btn_ExcelExport" runat="server" ImageUrl="~/Images/Excel-icon.png"
                            Width="30" Height="30" OnClick="btn_ExcelExport_Click" CausesValidation="false" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Button ID="btn_View" CommandName="Select" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"ClientID") %>'
                            runat="server" Text="View" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
        <ExportSettings Excel-Format="ExcelML" FileName="ClientExport" IgnorePaging="true"
            OpenInNewWindow="true"  ExportOnlyData="true" />
    </telerik:RadGrid>


protected void btn_ExcelExport_Click(object sender, ImageClickEventArgs e)
        {
            string[] UserRoles = Roles.GetRolesForUser();
 
            rg_Clients.MasterTableView.GetColumn("ClientID").Visible = false;
 
            //Dont need to see the filter boxes in the excel sheet
            foreach (GridFilteringItem Filter in rg_Clients.MasterTableView.GetItems(GridItemType.FilteringItem))
                Filter.Visible = false;
 
            //Data Admin and Site Admin can export all Clients, Sales Admin can export their own and who they are supervising,
            //  and Sales Person can only export their own             
            if (UserRoles.Contains("Sales Admin"))
            {
                string Source = PageController.GetUserFullName((Guid)Membership.GetUser().ProviderUserKey);
                List<string> Sources = ClientController.GetSupervisorSources((Guid)Membership.GetUser().ProviderUserKey);
                if (rg_Clients.MasterTableView.FilterExpression != String.Empty)
                    rg_Clients.MasterTableView.FilterExpression += "AND ";
                string QueryFilter = "([Sources] LIKE \'%" + Source + "%\') ";
                foreach (string S in Sources)
                    QueryFilter += "OR ([Sources] LIKE \'%" + S + "%\') ";
 
                rg_Clients.MasterTableView.FilterExpression += QueryFilter;
            }
            else if (UserRoles.Contains("Sales Person"))
            {
                string Source = PageController.GetUserFullName((Guid)Membership.GetUser().ProviderUserKey);
                if (rg_Clients.MasterTableView.FilterExpression != String.Empty)
                    rg_Clients.MasterTableView.FilterExpression += "AND ";
                rg_Clients.MasterTableView.FilterExpression += "([Sources] LIKE \'%" + Source + "%\') ";
            }
 
            rg_Clients.MasterTableView.ExportToExcel();

The rest of the columns are created programmatically on the first page load as some of the grid bound columns implement custom filters for google-like filtering and some are dropdownlists etc.
Chris
Top achievements
Rank 1
 answered on 04 Dec 2012
2 answers
58 views
Hello,

I have a Grid that has XXXX set. When I use it w/o the SEOPagingQueryStringKey it works fine, but when I set the SEOPagingQueryStringKey="PageId" it does not work any more. (stays on page 1)
(I saw a simulair post from 2008: http://www.telerik.com/community/forums/aspnet-ajax/grid/seo-paging.aspx#533423)

Here is the code: (Version 2012.3.1016.40)
<telerik:RadGrid ID="RadGrid1" Width="100%" Height="400px" Skin="Office2010Black" runat="server">
    <mastertableview autogeneratecolumns="false" allowsorting="true" allowpaging="true" pagesize="5" datakeynames="Id" clientdatakeynames="Id">
        <Columns>
            <telerik:GridButtonColumn UniqueName="RowSelector1" CommandName="Select" CommandArgument="" ButtonType="ImageButton" Text="Open demand" ImageUrl="~/styles/images/icon/playblue_16x16.png" HeaderStyle-Width="25px" Resizable="false" />
            <telerik:GridBoundColumn DataField="Id" HeaderText="Id" AllowSorting="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Description" HeaderText="Description" AllowSorting="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Street" HeaderText="Street" AllowSorting="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ZipCode" HeaderText="ZipCode" AllowSorting="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="City" HeaderText="City" AllowSorting="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Picture" HeaderText="Picture" AllowSorting="true">
            </telerik:GridBoundColumn>
        </Columns>
        <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric"
                      SEOPagingQueryStringKey="PageId" EnableSEOPaging="true" />      
    </mastertableview>
    <clientsettings allowcolumnhide="true" allowcolumnsreorder="false" allowdragtogroup="false" allowexpandcollapse="true" allowgroupexpandcollapse="true" enablepostbackonrowclick="false" enablerowhoverstyle="true" reordercolumnsonclient="true">
        <ClientEvents OnRowDblClick="prvOnRadGrid1_RowDblClick" />
        <Resizing AllowColumnResize="true" ShowRowIndicatorColumn="true" />
        <Selecting AllowRowSelect="true" />
        <Scrolling ScrollHeight="100%" AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="true" FrozenColumnsCount="0" />
    </clientsettings>
</telerik:RadGrid>

Regards,

Erik
Galin
Telerik team
 answered on 04 Dec 2012
6 answers
145 views
Hi,

I have a radchart and want to show multiple lines using datatable(I know datatable is not supported , but im adding series mannually). User selects thae date from calendar and I query the database for those range. so here is my code how I add the series I get one datatable at time and assign it to chart, i get datatable in this format :

Tours  agencyname  dtMonthno dtMonthBrand dtYear
6  agents May 2011
8  agents June 2011
agents 7  July 2011
23  agents 8  August 2011
126  agents 9  September 2011
101  agents 10  October 2011
85  agents  11  November 2011
92  agents 12  December 2011
115  agents 1  January 2012
102  agents 2  February 2012
48  agents March 2012  


foreach (string aId in aAgency)
                    {
                        DataTable dtBrands = count.GetBrandsChartData(Convert.ToDateTime(txtStartDate.Text), Convert.ToDateTime(txtEndDate.Text), Convert.ToInt32(aId));
 
                        bool morethenTwelve = false;
 
                        if (dtBrands.Rows.Count > 0)
                        {
                            ChartSeries brandChartSeries = new ChartSeries();
                            brandChartSeries.Name = dtBrands.Rows[0][1].ToString();
                            brandChartSeries.Type = ChartSeriesType.Line;
 
                            foreach (DataRow dr in dtBrands.Rows)
                            {
                                ChartSeriesItem chartitem = new ChartSeriesItem();
                                chartitem.YValue = Convert.ToDouble(dr["Tours"]);
 
                                if (morethenTwelve == false)
                                {
                                    dtMontno = Convert.ToInt32(dr["dtMonthno"]);
                                }
 
                                if (dtMontno == 12)
                                {
                                    chartitem.XValue = Convert.ToDouble(dr["dtMonthno"]);
                                    morethenTwelve = true;
                                    dtMontno = 13;
                                }
                                else if (dtMontno > 12)
                                {
                                    chartitem.XValue = Convert.ToDouble(dtMontno += 1);
                                    morethenTwelve = true;
                                }
                                else
                                {
                                    chartitem.XValue = Convert.ToDouble(dr["dtMonthno"]);
                                    morethenTwelve = false;
                                }
 
                                
                                brandChartSeries.AddItem(chartitem);
 
                                radBrands.PlotArea.XAxis[dtMonth - 1].TextBlock.Text = dr["dtMonthBrand"].ToString();
                            }
 
                            radBrands.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Inside;
 
                            radBrands.ChartTitle.TextBlock.Text = "Brands";
                            radBrands.PlotArea.XAxis.AutoScale = false;
                             
                            radBrands.AddChartSeries(brandChartSeries);
                            radBrands.Series.Add(brandChartSeries);
                        }
                    }


Now I am doing the if statement in above code so that the line doesn't come back to 1 axis once the dtmonthno is more than 12.

My question is how do I show these month names in x-axis i have tried setting the autoscale to false and trying to set the x-axis but simply doesnt work here is my code for it that i add in the above foreach loop:

radBrands.PlotArea.XAxis.AddRange(1, 16, 1);
int dtMonth = Convert.ToInt32(dr["dtMonthno"]);
radBrands.PlotArea.XAxis[dtMonth - 1].TextBlock.Text = dr["dtMonthBrand"].ToString();

Your help would be greatly appreciated.

Thanks
Joseph
Top achievements
Rank 1
 answered on 04 Dec 2012
2 answers
90 views
I have a radchart with a dataTable but no legend.  I know it is possible to customize items in the chart legend, but is it possible to customize the legend on the radchart dataTable?  
Ed
Top achievements
Rank 1
 answered on 04 Dec 2012
1 answer
64 views
Good morning, all.

I have a question regarding the state strings stored in a SQL server.  I have some code in which a user selects a dock from a menu, as well as a zone in which to place the dock.  The docks are created properly and their states are saved as they should be, but I've noticed that any docks with "Closed":"True" are never being deleted from the string that's stored server-side.  For example, I have one user's string with about 34 docks in it, but only 1 of them is open and rendering (which is functioning correctly).  Is there something I'm missing that will get rid of the other 33 docks that are closed?
Jeff
Top achievements
Rank 1
 answered on 04 Dec 2012
2 answers
117 views
Okay so here's the problem I am having.  I am wanting to show a multicolumn radcombobox in a radgrid from a custom inline edit form (user control).  I can get it to work fine on a page but from what I can tell when you run the same code from a user control that is being referenced by a radgrid for CRUD.  What is happening is that the dynamic template that I am creating doesn't get applied until after that data is bound.  From the looks of it the page load doesn't get touched at all.  So from what I can tell I am trying to call a databind within a databind which is my problem.

So for the radgrid when you use a custom form you call most of your bindings in the

private void InitializeComponent()
{
    this.DataBinding += new System.EventHandler(this.RandomName_DataBound);
}

and then you can bind lists etc. in there.  This is not a problem.  I can even databind the combobox.  Where the problem comes in is when I want to databind with a multicolumn format on the combobox. 

ComboBox.ItemTemplate = new ItemTemplate();
ComboBox.ItemDataBound += ComboBox_ItemDataBound;
ComboBox.Width = Unit.Pixel(500);
ComboBox.AllowCustomText = true;
ComboBox.MarkFirstMatch = true;
 
ComboBox.DataSource = GetVendorList();
ComboBox.DataTextField = "Name";
ComboBox.DataBind();
foreach (RadComboBoxItem item in ComboBox.Items)
{
    item.DataBind();
}

The above code is in the system event handler databound method.

protected void RandomName_DataBound(object sender, EventArgs e)
{
    // do stuff here
}

The problem from what I can see is that the Template that I am creating isn't firing until after the data is bound to the grid so it doesn't format the multicolumns properly.

class ItemTemplate : ITemplate
{
    public void InstantiateIn(Control container)
    {
        Table table = new Table();
        table.Width = Unit.Percentage(100);
        TableRow mainRow = new TableRow();
        TableCell cell1 = new TableCell();
        cell1.Width = Unit.Percentage(40);
        cell1.DataBinding += new EventHandler(cell1_DataBinding);
 
        mainRow.Cells.Add(cell1);
        TableCell cell2 = new TableCell();
        cell2.DataBinding += new EventHandler(cell2_DataBinding);
        cell2.Width = Unit.Percentage(30);
        mainRow.Cells.Add(cell2);
 
        TableCell cell3 = new TableCell();
        cell3.DataBinding += new EventHandler(cell3_DataBinding);
        cell3.Width = Unit.Percentage(30);
        mainRow.Cells.Add(cell3);
        table.Rows.Add(mainRow);
        container.Controls.Add(table);
    }
 
    private void cell1_DataBinding(object sender, EventArgs e)
    {
        TableCell target = (TableCell)sender;
        RadComboBoxItem item = (RadComboBoxItem)target.BindingContainer;
        target.Text = (string)DataBinder.Eval(item, "Text");
    }
 
    private void cell2_DataBinding(object sender, EventArgs e)
    {
        TableCell target = (TableCell)sender;
        RadComboBoxItem item = (RadComboBoxItem)target.BindingContainer;
        target.Text = (string)DataBinder.Eval(item, "Attributes[\"Type\"]");
    }
 
    private void cell3_DataBinding(object sender, EventArgs e)
    {
        TableCell target = (TableCell)sender;
        RadComboBoxItem item = (RadComboBoxItem)target.BindingContainer;
        target.Text = (string)DataBinder.Eval(item, "Attributes[\"Phone\"]");
    }
 
}

Any help on a work around would be great.  I have gone through all of the forums and all of the different sections of the radgrid and radcombobox api to see if this was addressed and I didn't find anything.

Thanks,
Kevin
Nencho
Telerik team
 answered on 04 Dec 2012
1 answer
81 views
Hello Telerik team.

We found a problem tabstrip control.
we are using telerik version 2012.2.912.40

I created approximately 15 ~ 20 tabs, click tabstript's scroll button for moving end of right side.
and click the close button while tab count is 0.
sometimes tabcontrol is invisible or cut the left side tab area.

I implemented some codes for reproducing problem at radtabstrip control.
here is my code and screenshots

ScreenshotLinkHere!!!

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            //Put your JavaScript code here.
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadButtonAdd">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadTabStripContent" />
                        <telerik:AjaxUpdatedControl ControlID="LabelCount" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadButtonClose_Click">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadTabStripContent" />
                            <telerik:AjaxUpdatedControl ControlID="LabelCount" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <div style="height: 100px; background-color: gray;">
            <telerik:RadTabStrip ID="RadTabStripContent" runat="server" Skin="Simple" ScrollChildren="true" dir="LTL" EnableEmbeddedSkins="true"
                Visible="true">
                <TabTemplate>
                    <asp:Label ID="LabelTabName" runat="server" />
                    Tab
                </TabTemplate>
            </telerik:RadTabStrip>
        </div>
 
        <telerik:RadButton runat="server" ID="RadButtonAdd" Text="Add" OnClick="RadButtonAdd_Click"></telerik:RadButton>
 
        <telerik:RadButton runat="server" ID="RadButtonClose" Text="close" OnClick="RadButtonClose_Click"></telerik:RadButton>
 
        <asp:Label runat="server"  ID="LabelCount" Text="Tab Count:"></asp:Label>
    </form>
</body>
</html>

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
 
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    protected void RadButtonClose_Click(object sender, EventArgs e)
    {
        RadTabStripContent.Tabs.RemoveAt(RadTabStripContent.Tabs.Count -4);
 
        LabelCount.Text = "Tab Count:" + RadTabStripContent.Tabs.Count;
    }
    protected void RadButtonAdd_Click(object sender, EventArgs e)
    {
        RadTab tab = new RadTab();
         
        tab.Text = "TAB "+ (RadTabStripContent.Tabs.Count + 1).ToString();
 
        RadTabStripContent.Tabs.Add(tab);
 
        LabelCount.Text = "Tab Count:" + RadTabStripContent.Tabs.Count;
    }
}


Nencho
Telerik team
 answered on 04 Dec 2012
1 answer
151 views
I have a calculated column that will display positive and negative numbers. I want to change the negative numbers color to red. How would I go about doing this. Any help would be great.
Michael
Top achievements
Rank 1
 answered on 04 Dec 2012
7 answers
329 views

Hello techies,

We are using the RagGrid on a test page for performance testing.
We were surprised to notice that a simple page with 100 elements in the GRID takes on an average about 2 seconds. We are doing a load test on Win Server 2008 R2. We are not using a real database. We are using a STUB to generate the 100 odd elements.
The same STUB when used on ASP.net MVC page with simple HTML table rendering out performs the RadGrid Page. The MVC page takes about 0.37 seconds.

 

Test Environment : ASP.net 4.0 / RadControls for ASP.NET AJAX Q2 2011 SP1 / Windows Server 2008 R2 / IIS 7.5  / Application pool type “Integrated Pipeline”

Any ideas?

 

Advance thanks,
Clement
Pavlina
Telerik team
 answered on 04 Dec 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?