Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
73 views
Hey guys,

I'm trying to use the Telerik Chart Control after purchasing the ASP.NET Ajax control yesterday from yourselves, but i can't seem to get the bar chart to be stacked...

Here is my code: (ASP.NET)

<telerik:RadChart ID="RadChart1" runat="server" DefaultType="StackedBar">
            <PlotArea>
                <YAxis MaxValue="300" Step="10" AutoScale="True"  AxisMode="Extended">
                </YAxis>
             
            </PlotArea>
            <Series>
                 
            </Series>
        </telerik:RadChart>

and my c#:

string sql = string.Format("...");
DataTable openLeads = db.FillTable(sql);
 
 
if (openLeads.Rows.Count > 0)
{
    RadChart1.DataSource = openLeads;
 
    foreach (DataRow row in openLeads.Rows)
    {
        ChartSeries chrtSeries = new ChartSeries {Name = row["Description"].ToString()};
        chrtSeries.Type = ChartSeriesType.StackedBar;
        RadChart1.SeriesOrientation = ChartSeriesOrientation.Vertical;
        RadChart1.Series.Add(chrtSeries);
 
    }
    RadChart1.PlotArea.XAxis.DataLabelsColumn = "UserName";
    RadChart1.DataBind();
}

my sql query produces these results:


Description                                                    Count              Username
Passed back to sales - query log                 1                      TAtest
Rejected                                                       2                     TAtest
Telesales Assigned TA                                 1                     TAtest

I want the y-axis to be 10-300 in steps of 10.. min of 10
I want the x-axis to be the username
and the count of each Description to be each bar stacked per username..

Please see attachment of what i'm currently getting..

Thanks for any help,

Regards,

Michael

Petar Marchev
Telerik team
 answered on 10 Apr 2012
1 answer
199 views
Ive added a file download fucntion to my grid, its works perfectly well on my local development machine, but when i upload it to a hosted server, it wont work !  nothing seems to happen.  In development I get the file dialoge box open in the browser, yet on the live server I dont get that, just the spinning ajax icon

heres the column in my grid

<telerik:GridAttachmentColumn
                       MaxFileSize="1048576"
                       EditFormHeaderTextFormat="Download File:"
                       HeaderText="Download"
                       
                       AttachmentKeyFields="AudioID"
                       FileNameTextField="AudioPath"
                       DataTextField="SongTitle"
                       UniqueName="AttachmentColumn">
                   </telerik:GridAttachmentColumn>

I have this in client settings

<ClientSettings>
                        <ClientEvents OnCommand="gridCommand" />
                    </ClientSettings>
  and this javascript on the page


function gridCommand(sender, args) {
               if (args.get_commandName() == "DownloadAttachment") {
                   var manager = $find('<%= RadAjaxManager.GetCurrent(Page).ClientID %>');
                   manager.set_enableAJAX(false);
 
                   setTimeout(function () {
                       manager.set_enableAJAX(true);
                   }, 0);
               }
           }
  and finally, this is the server side code

protected void RadGridAudio_ItemCommand(object source, GridCommandEventArgs e)
        {
                         
            if (e.CommandName == RadGrid.DownloadAttachmentCommandName)
            {
                e.Canceled = true;
 
                GridDownloadAttachmentCommandEventArgs args = e as GridDownloadAttachmentCommandEventArgs;
                string fileName = args.FileName;
                long attachmentId = (int)args.AttachmentKeyValues["AudioID"];
                 
                BusinessLayer.RegistrationAudio audio = new RegistrationAudio();
                audio = registrationManager.GetRegistrationAudio(attachmentId);
                string filePath = audio.AudioPath.Substring(0, audio.AudioPath.LastIndexOf(@"\"));
                string _DownloadableProductFileName = audio.FileName;
 
                if (audio.AudioPath != null && audio.FileName != null)
                {
                    System.IO.FileInfo FileName = new System.IO.FileInfo(filePath + "\\" + _DownloadableProductFileName);
                    FileStream myFile = new FileStream(filePath + "\\" + _DownloadableProductFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
 
                    try
                    {
                        if (FileName.Exists)
                        {
                            HttpContext.Current.Response.Clear();
                            HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;attachment; filename=\"" + FileName.Name + "\"");
                            HttpContext.Current.Response.AddHeader("Content-Length", FileName.Length.ToString());
                            HttpContext.Current.Response.ContentType = "application/octet-stream";
                            HttpContext.Current.Response.TransmitFile(FileName.FullName);
                            HttpContext.Current.Response.Flush();
                        }
                        else
                        {
                            throw new Exception("File not found");
                        }
                    }
                    catch (Exception ex)
                    {
                        HttpContext.Current.Response.ContentType = "text/plain";
                        HttpContext.Current.Response.Write(ex.Message);
                    }
                    finally
                    {
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                    }
                }
 
            }
        }
  can anyone see where im going wrong ?
Andrey
Telerik team
 answered on 10 Apr 2012
1 answer
112 views
Hi!

I have developed asp.net with telerik components for about 1,5 years now.

I have found out that if I create radgrid on aspx that meets the following requirements, the clientSelectColumn starts to misbehave:
 * allow paging = false
 * allow scrolling on grids clientSettings
 * add some columns, including telerik:GridClientSelectColumn
 * on client side: window.onresize = resize();  <- resize the grid to fit the page on "onload" and "onresize".
f.ex:
function resize() {
    if (grid) {
        var w = document.documentElement.clientWidth;
        var h = document.documentElement.clientHeight -100;
        grid.get_element().style.height = h + "px";
        grid.repaint();
     }
}


 * on "OnNeedDataSource" event, load so much data that you have to scroll the page to reach bottom.

 * scroll down and select a line by clicking on clientselectcolumn checkbox.
 -> with every click the pages contains are moving upwards and off from the web browsers window.

I got the same results with IE 9 and Firefox 11 (not so much offset, but it jumped a few times though).
If i set the grids height to be a static value this problem doesn't show up.
Andrey
Telerik team
 answered on 10 Apr 2012
7 answers
224 views
Hi,

I'd like to create a simple grid with one column not from a database.
And, I'd like to add rows to this grid each time a button is clicked, with the value of a combobox.
I can't do that, it doesnt works.
I'm a beginner, could you please tell me how to make that?

Thanks
Caro
Top achievements
Rank 1
 answered on 10 Apr 2012
4 answers
332 views
Is it possible to have an image upload control in the insert / update templates? I have a grid i am using to edit / insert sections of a site that includes images and text.

Thanks.
Antonio Stoilkov
Telerik team
 answered on 10 Apr 2012
1 answer
722 views
I want to change the text displayed on a rad grid based on the current text it had
here is the code-behind in C#
EXAMPLE A
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = (GridDataItem)e.Item;
 
                //Edits the text value of the column "Flow"
                if (dataItem["Flow"].Text == "1")
                {
                    dataItem["Flow"].Text = "Outcome";
                }
                if (dataItem["Flow"].Text == "2")
                {
                    dataItem["Flow"].Text = "Income";
                }
            }
        }

An awkward workaround I found is to use a hidden column replica like this
EXAMPLE B
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = (GridDataItem)e.Item;
 
                //Edits the text value of the column "Flow"
                if (dataItem["FlowReplica"].Text == "1")
                {
                    dataItem["Flow"].Text = "Outcome";
                }
                if (dataItem["FlowReplica"].Text == "2")
                {
                    dataItem["Flow"].Text = "Income";
                }
            }
        }

This works nice, but not so nice when you are working with over 10 columns
that would make 10 more hidden replicas
Is there another way to make it work as I desired in the EXAMPLE A
thanks in advance
Princy
Top achievements
Rank 2
 answered on 10 Apr 2012
1 answer
62 views
I have clicked edit button of an item(Radgrid).

Now the particular row is in edit mode.

When i click the submit button.It should prompt me to save the edited row.

How can i achieve it.
Princy
Top achievements
Rank 2
 answered on 10 Apr 2012
3 answers
127 views
Hi, I need to personalizate the view for each element to show on the grid.

how can i make it?

I can insert code in the ItemTemplate ?
I need to do something like this:

if (eval(something).ToString() != "")
{
    <span style="font-weight: bold;">Something:</span><%# Eval("something") + "%>
}

I need it, because every row could have some empty column on it and I should not show the information about that column.

Shinu
Top achievements
Rank 2
 answered on 10 Apr 2012
2 answers
134 views
how do I create css in the site.css so it apply to all the editform in the web pages that contain radgrid control?

thanks
Henry
Top achievements
Rank 1
 answered on 10 Apr 2012
4 answers
240 views
Hello,

I have 3 grids nested inside a main grid using the NestedViewTemplate.  Everything works fine for binding and displaying the data.

The problem is I want to use a CommandItemTemplate in the nested grid to popup another window for inserting new parts.  I can make the
window pop-up, I just can not get the primary key from the top level grid to go with it.

I have tried all kinds of stuff, but I was hoping to do something like the snippet below to include the PlanID as an argument
to my javascript function:

<CommandItemTemplate> 
     <asp:Label ID="lblAddNewPart" Text="Add" runat="server"/>  
                      <href="#" onclick="return ShowAddPartForm('<%# Bind( "PlanID" ) %>');">Add New </a> 
</CommandItemTemplate> 


I am open to C# code behind to set the onclick attributes or javascript to dig around if necessary to get the PlanID from
the parent grid or the nested grid, it exists in both.

I have inserted sample markup below if that helps.

Thanks!

Tom

(Sorry for the blue, I should have typed before using the format code block?)




<
telerik:RadGrid ID="gridJobPlans" runat="server" DataSourceID="objJobPlans"   
    GridLines="None" AllowFilteringByColumn="True" AllowSorting="True"   
            AutoGenerateColumns="False"   
        onupdatecommand="gridJobPlans_UpdateCommand"   
         > 
              
<MasterTableView DataKeyNames="ID"   
        DataSourceID="obj1" CommandItemDisplay="TopAndBottom">  
          
 
     
 
    <NestedViewTemplate> 
    <asp:Label ID="PlanID" runat="server" Text='<%# Eval("ID") %>' /> 
        <telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="1"   
            MultiPageID="MultiPageSelectedJobPlan">  
            <Tabs> 
                <telerik:RadTab runat="server" Text="Documents"   
                    PageViewID="SelectedJobPlanDocs">  
                </telerik:RadTab> 
            </Tabs> 
        </telerik:RadTabStrip> 
        <telerik:RadMultiPage ID="MultiPageSelectedJobPlan" Runat="server"   
            Width="703px" SelectedIndex="2">  
            <telerik:RadPageView ID="Parts" runat="server">  
                <telerik:RadGrid ID="Grid" runat="server"   
                    AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True"   
                    AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"   
                    DataSourceID="objSelected2" GridLines="None" AllowAutomaticDeletes="true">  
                    <MasterTableView AutoGenerateColumns="False" DataKeyNames="ID, PlanID" 
                        CommandItemDisplay="TopAndBottom">  
                        <Columns> 
                            <telerik:GridBoundColumn DataField="ID" DataType="System.Int64" HeaderText="ID"   
                                ReadOnly="True" SortExpression="ID" UniqueName="ID" Display="false">  
                            </telerik:GridBoundColumn> 
                              
                            <telerik:GridBoundColumn DataField="PlanID" DataType="System.Int64"   
                                HeaderText="PlanID" SortExpression="PlanID" UniqueName="PlanID" Display="true">  
                            </telerik:GridBoundColumn> 
                              
                        </Columns> 
                          
                       <CommandItemTemplate> 
                    <asp:Label ID="lblAddNewPart" Text="Add" runat="server"/>  
                      <href="#" onclick="return ShowAddPartForm('<%# Bind( "PlanID" ) %>');">Add New </a> 
                    </CommandItemTemplate>    
                          
                    </MasterTableView> 
                </telerik:RadGrid> 
            </telerik:RadPageView> 
              
        </telerik:RadMultiPage> 
    </NestedViewTemplate> 
 
     
 
</MasterTableView> 
      
</telerik:RadGrid> 
 
eamon
Top achievements
Rank 1
 answered on 09 Apr 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?