Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
97 views
I want to display a chart that binds to a sqldatasource.
The select query of sqldatasource returns records where the first column is of type datetime (records of samples acquired every 5 minutes) and the remaning columns are of type  float (select query with a where clause that let me retrive data for a selected day).
I want to show the records returned by sqldatasource in a chart of type spline with two y axis where on x axis I have datetime in a custom format  showing only hours for the day selected (majortick xaxis set every hour).
Below is my code:

 
<telerik:RadChart ID="RadChart2" runat="server" Width="970px" AutoLayout="True" Skin="Vista" Height="500px" DefaultType="Spline" DataSourceID="SqlDataSource1" OnDataBinding="RadChart2_DataBinding" OnDataBound="RadChart2_DataBound">
      <Appearance Corners="Round, Round, Round, Round, 7">
          <FillStyle FillType="ComplexGradient">
              <FillSettings>
                  <ComplexGradient>
                      <telerik:GradientElement Color="243, 253, 255" />
                      <telerik:GradientElement Color="White" Position="0.5" />
                      <telerik:GradientElement Color="243, 253, 255" Position="1" />
                  </ComplexGradient>
              </FillSettings>
          </FillStyle>
          <Border Color="212, 221, 222" />
      </Appearance>
      <Series>
          <telerik:ChartSeries Name="Pac"  DefaultLabelValue="#Y{F1}"  Type="Spline"  DataYColumn="PAC" Appearance-ShowLabels="false">
              <Appearance>
                  <FillStyle MainColor="186, 207, 141" SecondColor="146, 176, 83">
                      <FillSettings GradientMode="Vertical">
                          <ComplexGradient>
                              <telerik:GradientElement Color="213, 247, 255" />
                              <telerik:GradientElement Color="193, 239, 252" Position="0.5" />
                              <telerik:GradientElement Color="157, 217, 238" Position="1" />
                          </ComplexGradient>
                      </FillSettings>
                  </FillStyle>
                  <TextAppearance TextProperties-Color="89, 89, 89">
                  </TextAppearance>
                  <Border Color="" />
              </Appearance>
          </telerik:ChartSeries>
          <telerik:ChartSeries Name="Pdc" Type="Spline"  DataYColumn="PDC" Appearance-ShowLabels="false">
              <Appearance>
                  <FillStyle MainColor="235, 140, 104" SecondColor="214, 110, 90">
                      <FillSettings GradientMode="Vertical">
                          <ComplexGradient>
                              <telerik:GradientElement Color="218, 254, 122" />
                              <telerik:GradientElement Color="198, 244, 80" Position="0.5" />
                              <telerik:GradientElement Color="153, 205, 46" Position="1" />
                          </ComplexGradient>
                      </FillSettings>
                  </FillStyle>
                  <TextAppearance TextProperties-Color="89, 89, 89">
                  </TextAppearance>
                  <Border Color="" />
              </Appearance>
          </telerik:ChartSeries>
 
          <telerik:ChartSeries DataYColumn="D_Mtrk"   Name="D_Mtrk" Type="Spline" YAxisType="Secondary" Appearance-ShowLabels="false">
              <Appearance>
                  <FillStyle MainColor="129, 192, 225" SecondColor="79, 129, 189">
                      <FillSettings GradientMode="Vertical">
                          <ComplexGradient>
                              <telerik:GradientElement Color="136, 221, 246" />
                              <telerik:GradientElement Color="97, 203, 234" Position="0.5" />
                              <telerik:GradientElement Color="59, 161, 197" Position="1" />
                          </ComplexGradient>
                      </FillSettings>
                  </FillStyle>
                  <TextAppearance TextProperties-Color="89, 89, 89">
                  </TextAppearance>
                  <Border Color="" />
              </Appearance>
          </telerik:ChartSeries>
 
      </Series>
      <Legend  Appearance-ItemAppearance-Position-AlignedPosition="BottomRight">
          <Appearance Dimensions-Margins="1px, 1%, 10%, 1px">
               
              <ItemTextAppearance TextProperties-Color="86, 88, 89">
              </ItemTextAppearance>
              <ItemMarkerAppearance Figure="Rectangle">
              </ItemMarkerAppearance>
              <FillStyle MainColor="">
              </FillStyle>
              <Border Color="" />
          </Appearance>
          <TextBlock>
              <Appearance  TextProperties-Color="86, 88, 89">
              </Appearance>
          </TextBlock>
      </Legend>
      <PlotArea>
            <DataTable Visible="true"  >
                 
              <Appearance    Dimensions-AutoSize="true"  Position-AlignedPosition="BottomRight" RenderType="AutoSize" ></Appearance>
          </DataTable>
          <XAxis >
              <Appearance Color="134, 134, 134" MajorTick-Color="134, 134, 134">
                  <MajorGridLines Color="196, 196, 196" Width="0" />
                  <TextAppearance TextProperties-Color="89, 89, 89">
                  </TextAppearance>
              </Appearance>
              <AxisLabel   Appearance-Visible="true">
                  <Appearance Visible="True" Dimensions-Paddings="1px, 1px, 10%, 1px"></Appearance>
 
                  <TextBlock Text="Time">
                      <Appearance TextProperties-Color="51, 51, 51">
                      </Appearance>
                  </TextBlock>
              </AxisLabel>
          </XAxis>
          <YAxis IsZeroBased="false" >
              <Appearance Color="134, 134, 134" MajorTick-Color="196, 196, 196" MinorTick-Color="196, 196, 196">
                  <MajorGridLines Color="196, 196, 196" />
                  <MinorGridLines Color="196, 196, 196" Width="0" />
                  <TextAppearance TextProperties-Color="89, 89, 89">
                  </TextAppearance>
              </Appearance>
              <AxisLabel Appearance-Visible="true" >
                  <Appearance Visible="True"></Appearance>
 
                  <TextBlock Text="Pac & Pdc [kW]"  >
                      <Appearance TextProperties-Color="220, 158, 119">
                      </Appearance>
                  </TextBlock>
              </AxisLabel>
          </YAxis>
          <YAxis2>
                <AxisLabel Appearance-Visible="true" >
                  <Appearance Visible="True"></Appearance>
 
                  <TextBlock Text="D_Mtrk [W/m^2]"  >
                      <Appearance TextProperties-Color="220, 158, 119">
                      </Appearance>
                  </TextBlock>
              </AxisLabel>
          </YAxis2>
          <Appearance Dimensions-Margins="19%, 90px, 12%, 9%">
              <FillStyle MainColor="Transparent" SecondColor="Transparent">
              </FillStyle>
              <Border Color="WhiteSmoke" />
          </Appearance>
      </PlotArea>
      <ChartTitle>
          <Appearance Dimensions-Margins="3%, 1px, 1px, 6%">
              <FillStyle MainColor="">
              </FillStyle>
          </Appearance>
          <TextBlock Text="">
              <Appearance TextProperties-Color="86, 88, 89" TextProperties-Font="Verdana, 22px">
              </Appearance>
          </TextBlock>
      </ChartTitle>
  </telerik:RadChart>
With the code above I obtain a chart as in the attached file, it does not show hour on x axis.

If I use DataXColumn="date_time" (first column of my sqldatasource query of type datetime) I obtain the following error:
"The type of column with name  date_time is not numeric" I tried:
if (!IsPostBack)
            {
 
                // select a date for which I want to show data
                DateTime ds = RadDatePickerStart.SelectedDate.Value;
                
                RadChart2.PlotArea.XAxis.AutoScale = false;
                RadChart2.PlotArea.XAxis.IsZeroBased = false;
                RadChart2.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime;
                RadChart2.PlotArea.XAxis.Appearance.MinorTick.Visible = false;
                   
                RadChart2.PlotArea.XAxis.Appearance.CustomFormat = "HH";
                RadChart2.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = -90;
                RadChart2.PlotArea.XAxis.AddRange(RadDatePickerStart.SelectedDate.Value.ToOADate(), RadDatePickerStart.SelectedDate.Value.AddHours(24).ToOADate(), 0.004);
}
but this does not still work. What's wrong? Best regards.
Rosko
Telerik team
 answered on 25 Jun 2013
1 answer
73 views
Hello,

I want to add a column that works like a GridEditCommandColumn but using a GridButtonColumn. This works but with one problem. The editor opens like in insert mode, but it should open below the current row where the user clicked the command.
Here is my approach:

In the GriItemCommand event handler, I check if my command was clicked and save the internal id (of the database record) of the row:
private void GridItemCommand(object sender, GridCommandEventArgs e)
      {
          if (e.CommandName == "MyCommand")
         {
            this.mycommand = true;
            this.currentSelection = int.Parse(((GridDataItem)(e.Item)).EditFormItem.ParentItem[Grid.IdColumnUniqueName].Text);
            this.parentItem = ((GridDataItem)(e.Item)).EditFormItem.ParentItem;
         }
      }

In the ItemDataBound event, I initialize the control which should be displayed (it gets the id of the row I saved to this.currentSelection.
In OnPreRender I call this code to display the editor:

Grid.MasterTableView.IsItemInserted = true;
Grid.Rebind();

While the editor is opened with the correct object, it is opened like insert mode (at top) and not below the clicked row. How can I tell the GridItem to open below the correct row?

Thanks!

Edit: I'm using GridEditFormType.Template as EditFormType
And I have already a GridEditCommandColumn in my grid and since you can only have one, I have to use a different apporach like above.
Shinu
Top achievements
Rank 2
 answered on 25 Jun 2013
11 answers
435 views
hi guys
i am trying the editor recently, it is great ! BUT UNFORTUNATELY , you do not give the user control over the text flow direction (RTL & LTR) by placing control buttons in the tool bar !
if i import my text from word , it is perfectly placed in the editor contenet
i can even view html and type <p dir="rtl" /p> anywhere i need to change direction and the editor control response to that gracefully
so , if you can add that visual control or tell me if there is  way to do it myself

thanks
TJ
F187336
Top achievements
Rank 1
 answered on 25 Jun 2013
1 answer
175 views
I'm using a RadTooltipManager with AutoTooltipify set on a zone using ToolTipZoneID.  Within that zone, I'm changing one some of the tooltipped elements' titles in Javascript.  I'm not using UpdatePanels for this and am sticking with straight jQuery.  Since the TooltipManager removes the title of the element when it "tooltipifies" it, and I'm now changing the title, it adds the title attribute back onto the element and I end up with two tooltips.  The RadTooltip shows the old title, and the browser pops up the new one.  Is there a way to signal the TooltipManager to update itself and reset the tooltips to current values (and remove the new title attribute as it did on initial load)?  Any guidance would be appreciated.

--
Ken
Marin Bratanov
Telerik team
 answered on 25 Jun 2013
5 answers
966 views
Hello!

I'm having problems with accessing a radgrids columns manually added from source code, I have loads of columns, and I don't want to repeat myself, adding the Width and change the headertext, according to my algorithm manually on each column.

Therefore I've been trying to find a way to set them automatically in the codebehind, however I am having problems accessing all the columns and settings. 

The columns is as said not generated automatically.

Any idea?

Before When I have had the columns auto generated I have easily achieved this by using the Event ColumnCreated

protected void radGrid_ColumnCreated(object sender, GridColumnCreatedEventArgse)
{
                e.Column.HeaderStyle.Width = 200;
                e.Column.ItemStyle.Width = 200;
                e.Column.HeaderText = "test";
               e.Column.UniqueName = "test2"
}

Now I want to do the same but with manually added columns? (The ColumnCreated event is only triggered when the columns are auto generated, sadly =()

So something like this, by what I assume listening to the ItemDataBound event?

protected void radGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
      //Set column Width and Height and also the columns Header text and Unique name.
 }



Appreciate any help :) Hope I made it clear enough to understand :) 

Thanks in advance! ( Couldnt find any threads similair that accessed the HeaderStyle nor the UniqueName properties of a column)
Nicklas
Top achievements
Rank 1
 answered on 25 Jun 2013
2 answers
149 views
Hi there,
I created a control that inherits from RadGrid to include a RadWindow editing feature, similar to the sample here http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=grid
The main difference is that I do not want to use an external page, as in the sample above, but I want to use a template to be dynamically loaded in the RadWindow. Also, I'd like to handle all load & save events using the RadGrid ItemCommand.
So I created an ITemplate EditWindowTemplate property in my control and I instantiate it in the RadWindow contentcontainer when needed.
This is the code I use to extend the RadGrid js client 
Telerik.Web.UI.RadGrid.prototype.showEditItemForm = function (itemIndex) {
    this.gridItemIndex = itemIndex;
    $find(this.windowId).show();
    __doPostBack(this.panelId, itemIndex);
    return false;
}
Telerik.Web.UI.RadGrid.prototype.saveChanges = function () {
    if (this.gridItemIndex > -1)
        this.get_masterTableView().fireCommand('Update', '');
    else
        this.get_masterTableView().fireCommand('PerformInsert', '');
}
So, when the user click the "Add new" link or an Edit link, I start a partial postback that loads the RadWindow contents, using an UpdatePanel.
This is the UpdatePanel PreRender method I use to display the UI and pass the edit item index to the server
void pnlWnd_PreRender(object sender, EventArgs e)
        {
            //Handle updatepanel postback, show edit window
            string eventTarget = HttpContext.Current.Request.Params["__EVENTTARGET"] as string;
            int eventArg = -1;
            if (!string.IsNullOrEmpty(eventTarget) && eventTarget == pnlWnd.ClientID && int.TryParse(HttpContext.Current.Request.Params["__EVENTARGUMENT"], out eventArg))
            {
                //CreateEditWindow();
                editWindowContainer.Visible = true;
                if (eventArg > -1)
                {
                    GridCommandEventArgs args = new GridCommandEventArgs(this.Items[eventArg], this, new CommandEventArgs(RadGrid.EditCommandName, null));
                    OnItemCommand(args);
                }
                else
                {
                    MasterTableView.IsItemInserted = true;
                    GridCommandEventArgs args = new GridCommandEventArgs(MasterTableView.GetItems(GridItemType.CommandItem)[0], this, new CommandEventArgs(InitInsertCommandName, -1));
                    OnItemCommand(args);
                }
            }
        }
If the user clicks on the Add link, I fire the InitInsert event, if he clicks an Edit link I fire the Edit event.
Last, I handle the ItemCommand event in a page to respond to each event: Edit (load an item and show the edit form), InitInsert (show empty edit form), Update (the user saved a change) and PerformInsert (the user saved a new item).
When I create a new item everything works, but when I try to save a change to an existing item I get

Specified argument was out of the range of valid values.
Parameter name: ItemHierarchicalIndex

What am I doing wrong?
Thanks!
Luca B
Top achievements
Rank 1
 answered on 25 Jun 2013
1 answer
109 views
Hello every one

i have radgride to show invoices list when i edit invoice in radwindow he show me the data for previous invoice

for example
When I try to edit invoice no 1 he show me the data correct in radwindow for first time
but after close radwindow then I try to edit invoice no 2 he show me in radwindow the data for invoice no 1


any one can help me

Thanks
Marin Bratanov
Telerik team
 answered on 25 Jun 2013
1 answer
191 views

Hello everyone,

i need your help for getting the value of the DataField from ClientDataKeyNames array of the MasterTable and even without AllowRowSelect = "True" 
All I need is to CLICK BUTTON ONLY WITHOUT AllowRowSelect = True 
Once I click "Remove Location" button, I am still getting error that we don't get any values from ClientDataKeyName.  

In UserControl 
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function OnClientClickingApprovedLocations(sender, args) {
                var callBackFunction2 = Function.createDelegate(sender, function (argument) {
                    if (argument) {
                        this.click();
                    }
                });
 
                var Master = $find("<%=rgRequestorlocations.ClientID %>").get_masterTableView();
                var SelectedItem = Master.get_selectedItems()[0];
 
                var location_name = SelectedItem.getDataKeyValue("location_name"); // get the DataKeyValue of selected item
                var role = SelectedItem.getDataKeyValue("role");
                var duty = SelectedItem.getDataKeyValue("duty");
 
 
                if (duty == "P") {
                    if (role == "Privacy Officer") {
 
                        roletext = "Are you sure you want to remove this role location?";
                        radconfirm(roletext, callBackFunction2, 300, 100, null, "Delete");
                        args.set_cancel(true);
                    }
                    else {
                        roletext = "Please confirm the Primary " + role + " for " + location_name + " will be removed " + "" + "?";
                        radconfirm(roletext, callBackFunction2, 300, 100, null, "Delete");
                        args.set_cancel(true);
                    }
 
                }
                else {
                    roletext = "Are you sure you want to remove this role location?";
                    radconfirm(roletext, callBackFunction2, 300, 100, null, "Delete");
                    args.set_cancel(true);
                }
            }
        </script>
    </telerik:RadScriptBlock>

<telerik:RadGrid ID="rgRequestorlocations" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" OnNeedDataSource="rgRequestorlocations_NeedDataSource" OnItemCommand="rgRequestorlocations_ItemCommand" OnItemDataBound="rgRequestorlocations_ItemDataBound">
                                            <MasterTableView DataKeyNames="location_pk, user_id, role,location_name, duty" ClientDataKeyNames="location_pk, user_id, role,location_name, duty">
 
                                                <CommandItemSettings ExportToPdfText="Export to PDF" />
                                                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                                                    <HeaderStyle Width="20px" />
                                                </RowIndicatorColumn>
                                                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                                                    <HeaderStyle Width="20px" />
                                                </ExpandCollapseColumn>
                                                <Columns>
                                                    <telerik:GridBoundColumn DataField="user_id" FilterControlAltText="Filter location_pk column" HeaderText="User ID" UniqueName="user_id" Visible="False"></telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="location_pk" FilterControlAltText="Filter location_pk column" HeaderText="Location ID" UniqueName="location_pk" Visible="False"></telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="location_name" FilterControlAltText="Filter location_name column" HeaderText="Location Name" UniqueName="location_name"></telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="role" FilterControlAltText="Filter role column" HeaderText="Role" UniqueName="role"></telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="duty" FilterControlAltText="Filter role column" HeaderText="duty" UniqueName="duty" Visible="false"></telerik:GridBoundColumn>
                                                    <%--             <telerik:GridButtonColumn ButtonType="PushButton" FilterControlAltText="Filter deletecolumn column" ConfirmText="Are you sure you want to remove this role location?"
                                ConfirmDialogType="RadWindow"
                                ConfirmTitle="Remove Role Location?" HeaderText="Remove Role" Text="Remove Role" UniqueName="deletecolumn" CommandName="DeleteRoleLocation">
                            </telerik:GridButtonColumn>--%>
                                                    <telerik:GridTemplateColumn UniqueName="rbDelete">
                                                        <ItemTemplate>
                                                            <telerik:RadButton ID="rbDelete" onr runat="server" Text="Remove Role" OnClientClicking="OnClientClickingApprovedLocations" Value="" CommandName="DeleteRoleLocation">
                                                            </telerik:RadButton>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                </Columns>
                                                <EditFormSettings>
                                                    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                                </EditFormSettings>
                                                <PagerStyle PageSizeControlType="RadComboBox" />
                                            </MasterTableView>
                                            <PagerStyle PageSizeControlType="RadComboBox" />
                                            <ClientSettings>
                                                <Selecting AllowRowSelect="True"></Selecting>
 
                                            </ClientSettings>
 
                                            <FilterMenu EnableImageSprites="False"></FilterMenu>
                                        </telerik:RadGrid>

Eyup
Telerik team
 answered on 25 Jun 2013
1 answer
125 views
Hello friends
 
    I want to count telerik:GridBoundColumn in the radgrid so how can i do this?
Princy
Top achievements
Rank 2
 answered on 25 Jun 2013
3 answers
268 views
How to get Export working with GridButtonColumns ?  I want my LinkButton.Text data in the exported excel.


Shinu explains the problem here:
http://www.telerik.com/community/forums/aspnet-ajax/grid/exporting-data-to-excel.aspx#526940

but that link is not sufficient and does not present a solution.

Thanks.
Kostadin
Telerik team
 answered on 25 Jun 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?