Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
83 views
Hi,

I am trying to create a Radgrid from the codebehind at runtime. The grid works fine with paging, but the problem is i need to have the export functionality I tried the following code along with the grid creation even then the grid header is not displayed.

               RadGrid1.MasterTableView.CommandItemSettings.ShowExportToPdfButton = true;
               RadGrid1.MasterTableView.CommandItemSettings.ShowExportToExcelButton = true;
               RadGrid1.MasterTableView.CommandItemSettings.ShowRefreshButton = true;
               RadGrid1.ExportSettings.HideStructureColumns = true;
               RadGrid1.ExportSettings.ExportOnlyData = true;
               RadGrid1.ExportSettings.IgnorePaging = true;
               RadGrid1.ExportSettings.OpenInNewWindow = true;

Am i missing something? 

Thanks in advance.

Daniel
Telerik team
 answered on 26 May 2011
2 answers
779 views
Hi,

i have a RadGrid with templated columns. I have a ReportLevel RadCombobox & a CostCentreLow RadComboBox in the edit template.
The CostCentreLow Radcombobox is populated from a SqlDatasource but what i want to do is base the sqldatasource select command on the value selected in the ReportLevel combobox & then rebind datasource to the CostCentreLow combobox. I need this to work on the reportlevel selectedIndexChanged.
I have tried the RadGrid ItemCreated method but i get a databind error when i try to change the SqlDataSource select command in the ReportLevel SelectedIndexChanged event & it doesn't work if i try to bind the datasource in the Radgrid ItemCreated event (as i need the datasource changed based on the value in the ReportLevel ComboBox).

here is the code for my project:

<telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True"
    AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True"
    AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Skin="Web20" 
    Width="99%" AllowFilteringByColumn="True" OnItemUpdated="RadGrid1_ItemUpdated"
    OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted" 
    OnDataBound="RadGrid1_DataBound" OnItemDataBound="RadGrid1_ItemDataBound"  OnItemCreated="RadGrid1_ItemCreated"
    onitemcommand="RadGrid1_ItemCommand" AllowSorting="True" Culture="en-GB" 
    CssClass="Grid" Font-Size="X-Small" Font-Names="verdana" 
    PageSize="15"   >
    <PagerStyle Mode="NextPrevAndNumeric" />
    <AlternatingItemStyle BackColor="#E8F1FF" />
    <MasterTableView  CommandItemDisplay="TopAndBottom" DataKeyNames="U_ID"  
        DataSourceID="SqlDataSource1" HorizontalAlign="NotSet" AutoGenerateColumns="False">
        <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
        <Columns>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                <ItemStyle CssClass="MyImageButton" Width="20px" />
            </telerik:GridEditCommandColumn>
            <telerik:GridTemplateColumn HeaderText="ID" SortExpression="U_ID" UniqueName="U_ID" AllowFiltering="true"
                EditFormColumnIndex="0" FilterControlWidth="50%" DataField="U_ID" >
                <ItemTemplate>
                    <asp:Label runat="server" CssClass="Label2" Width="30px" ID="U_ID" Text='<%# Eval("U_ID") %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="UserName" SortExpression="UserName" UniqueName="UserName" AllowFiltering="true"
                EditFormColumnIndex="0" FilterControlWidth="70%" DataField="UserName" >
                <EditItemTemplate>
                    <span style="font-size:13px;color:Red;">
                    <telerik:RadTextBox runat="server" Width="200px" Text='<%# Bind("UserName") %>' ID="UserName" Visible="true" MaxLength="12" >
                    </telerik:RadTextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator9" ControlToValidate="UserName"
                    ErrorMessage="*" runat="server">
                    </asp:RequiredFieldValidator>
                    </span>                            
                </EditItemTemplate>
                <InsertItemTemplate>
                    <span style="font-size:13px;color:Red;">
                    <telerik:RadTextBox runat="server" Width="200px" Text='<%# Bind("UserName") %>' ID="UserName" Visible="true" MaxLength="12" >
                    </telerik:RadTextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator10" ControlToValidate="UserName"
                    ErrorMessage="*" runat="server">
                    </asp:RequiredFieldValidator>
                    </span>       
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label runat="server" CssClass="Label2" Width="80px" ID="UserName" Text='<%# Eval("UserName") %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Report Level" SortExpression="ReportLevel" UniqueName="ReportLevel" AllowFiltering="true"
                EditFormColumnIndex="0" FilterControlWidth="70%" DataField="ReportLevel" >
                <EditItemTemplate>
                    <span style="font-size:13px; color:Red;">
                    <telerik:RadComboBox runat="server" Width="205px" Height="100px"
                        EmptyMessage="Select a value"
                        HeaderText="ReportLevel"  SelectedValue='<%# Bind("ReportLevel") %>'
                        UniqueName="ReportLevel" ID="ReportLevel"  >
                        <Items>
                        <telerik:RadComboBoxItem Value="" Text="" />
                        <telerik:RadComboBoxItem Value="CC" Text="CC" />
                        <telerik:RadComboBoxItem Value="DIR" Text="DIR" />
                        </Items>
                    </telerik:RadComboBox
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" ControlToValidate="ReportLevel"
                    ErrorMessage="*" runat="server">
                    </asp:RequiredFieldValidator>
                    </span>                        
                </EditItemTemplate>
                <InsertItemTemplate>
                    <span style="font-size:13px; color:Red;">
                    <telerik:RadComboBox runat="server" Width="205px" Height="100px"
                        EmptyMessage="Select a value"
                        HeaderText="ReportLevel"  SelectedValue='<%# Bind("ReportLevel") %>'
                        UniqueName="ReportLevel" ID="ReportLevel"  >
                        <Items>
                        <telerik:RadComboBoxItem Value="" Text="" />
                        <telerik:RadComboBoxItem Value="CC" Text="CC" />
                        <telerik:RadComboBoxItem Value="DIR" Text="DIR" />
                        </Items>
                    </telerik:RadComboBox
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="ReportLevel"
                    ErrorMessage="*" runat="server">
                    </asp:RequiredFieldValidator>
                    </span>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label runat="server" CssClass="Label2" Width="80px" ID="lblReportLevel" Text='<%# Eval("ReportLevel") %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Cost Centre Low" SortExpression="CostCentreLow" UniqueName="CostCentreLow" AllowFiltering="true"
                EditFormColumnIndex="0" FilterControlWidth="70%" DataField="CostCentreLow" >
                <EditItemTemplate>
                    <span style="font-size:13px; color:Red;" runat="server"  >
                        <telerik:RadComboBox ID="CostCentreLow" runat="server" Enabled="false" 
                            DataSourceID="DS_CostCentre" DataTextField="costcentre" 
                            DataValueField="costcentre" DropDownWidth="200px"
                            SelectedValue='<%# Bind("CostCentreLow") %>'  Width="205px" TabIndex="8" Font-Size="X-Small" Font-Names="Verdana" AppendDataBoundItems="True" >
                        </telerik:RadComboBox>  
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="CostCentreLow"
                    ErrorMessage="*" runat="server">
                    </asp:RequiredFieldValidator>
                    </span>                                                 
                </EditItemTemplate>
                <InsertItemTemplate>
                    <span style="font-size:13px; color:Red;">
                        <telerik:RadComboBox ID="CostCentreLow" runat="server" 
                            DataSourceID="DS_CostCentre" DataTextField="costcentre" 
                            DataValueField="costcentre" DropDownWidth="200px"
                            SelectedValue='<%# Bind("CostCentreLow") %>'  Width="205px" TabIndex="8" Font-Size="X-Small" Font-Names="Verdana" AppendDataBoundItems="True" >
                        </telerik:RadComboBox>  
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="CostCentreLow"
                    ErrorMessage="*" runat="server">
                    </asp:RequiredFieldValidator>
                    </span
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label runat="server" CssClass="Label2" Width="80px" ID="CostCentreLow" Text='<%# Eval("CostCentreLow") %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Cost Centre High" SortExpression="CostCentreHigh" UniqueName="CostCentreHigh" AllowFiltering="true"
                EditFormColumnIndex="0" FilterControlWidth="70%" DataField="CostCentreHigh" >
                <EditItemTemplate>
                    <span style="font-size:13px; color:Red;">
                        <telerik:RadComboBox ID="CostCentreHigh" runat="server" Enabled="false" 
                            DataSourceID="DS_CostCentre" DataTextField="costcentre" 
                            DataValueField="costcentre" DropDownWidth="200px"
                            SelectedValue='<%# Bind("CostCentreHigh") %>'  Width="205px" TabIndex="8" Font-Size="X-Small" Font-Names="Verdana" AppendDataBoundItems="True" >
                        </telerik:RadComboBox>  
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="CostCentreHigh"
                    ErrorMessage="*" runat="server">
                    </asp:RequiredFieldValidator>
                    </span>                          
                </EditItemTemplate>
                <InsertItemTemplate>
                    <span style="font-size:13px; color:Red;">
                        <telerik:RadComboBox ID="CostCentreHigh" runat="server" 
                            DataSourceID="DS_CostCentre" DataTextField="costcentre" 
                            DataValueField="costcentre" DropDownWidth="200px"
                            SelectedValue='<%# Bind("CostCentreHigh") %>'  Width="205px" TabIndex="8" Font-Size="X-Small" Font-Names="Verdana" AppendDataBoundItems="True" >
                        </telerik:RadComboBox>  
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="CostCentreHigh"
                    ErrorMessage="*" runat="server">
                    </asp:RequiredFieldValidator>
                    </span
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label runat="server" CssClass="Label2" Width="80px" ID="CostCentreHigh" Text='<%# Eval("CostCentreHigh") %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow"
                ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                UniqueName="DeleteColumn">
                <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
            </telerik:GridButtonColumn>
        </Columns>
        <EditFormSettings ColumnNumber="2" CaptionDataField="U_ID" CaptionFormatString="Edit properties of Record {0}" InsertCaption="New Record">
           <FormTableItemStyle Wrap="False"></FormTableItemStyle>
            <FormTableStyle CellPadding="2" CellSpacing="0" BackColor="#F2FFEC" Height="60px"></FormTableStyle>
            <FormMainTableStyle CellPadding="3" CellSpacing="0" BackColor="#F2FFEC" Width="100%"></FormMainTableStyle>
            <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
            <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="#F2FFEC"  Width="100%" />
            <FormTableStyle CellSpacing="0" CellPadding="2" Height="60px" BackColor="#F2FFEC" />
            <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
            <EditColumn ButtonType="ImageButton" InsertText="Insert Record" UpdateText="Update Record"
                UniqueName="EditCommandColumn1" CancelText="Cancel edit">
            </EditColumn>
            <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
        </EditFormSettings>
    </MasterTableView>
    <ClientSettings>
        <Selecting AllowRowSelect="True" />
        <ClientEvents OnRowDblClick="RowDblClick" />
        <Selecting AllowRowSelect="True"></Selecting>
        <ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
    </ClientSettings>
    <EditItemStyle BackColor="#F2FFEC" />
    <ActiveItemStyle BackColor="#FFF8D9" BorderColor="#FFF8D9" BorderStyle="Solid" 
        BorderWidth="1px" />
    <ActiveItemStyle BackColor="#FFF8D9" BorderColor="#FFF8D9" BorderWidth="1px" 
        BorderStyle="Solid"></ActiveItemStyle>
    <SelectedItemStyle BackColor="#FFF8D9" BorderColor="#FFF8D9" 
        BorderStyle="Solid" BorderWidth="1px" />
    <FilterMenu EnableImageSprites="False"></FilterMenu>
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Web20"></HeaderContextMenu>
</telerik:RadGrid>

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            //the dropdown list will be the first control in the Controls collection of the corresponding cell  
            RadComboBox list = (e.Item as GridEditableItem)["ReportLevel"].Controls[1] as RadComboBox;
            //attach SelectedIndexChanged event for the drodown control this.combo_SelectedIndexChanged
            list.AutoPostBack = true;
            //list.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(this.list_SelectedIndexChanged);
            list.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(list_SelectedIndexChanged);
            
        }
}
void list_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
    //first reference the edited grid item through the NamingContainer attribute
    GridEditableItem editedItem = (sender as RadComboBox).NamingContainer as GridEditableItem;
    //the dropdown list will be the first control in the Controls collection of the corresponding cell  
    //for custom edit forms (WebUserControl/FormTemplate) you can find the column editor with the FindControl(controlId) method  
    RadComboBox ddRepLev = editedItem["ReportLevel"].Controls[1] as RadComboBox;
    RadComboBox ddCostCen = editedItem["CostCentreLow"].Controls[1] as RadComboBox;
    if (ddRepLev.SelectedValue == "CC")
    {
        this.DS_CostCentre.SelectCommand = "SELECT '' AS costcentre UNION SELECT DISTINCT SEGMENT_CODE AS costcentre FROM ORACLE_DS_GL_CoA_Segments WHERE (SEGMENT_NUMBER = 2) "; //AND (EFFECTIVE_STATUS = 'Active')
        this.DS_CostCentre.DataBind();
    }
    else
    {
        this.DS_CostCentre.SelectCommand = "SELECT '' AS costcentre UNION SELECT DISTINCT PARENT_CODE_L2 AS costcentre FROM ORACLE_DS_GL_CoA_Segments WHERE (SEGMENT_NUMBER = 2)  "; //AND (EFFECTIVE_STATUS = 'Active')
        this.DS_CostCentre.DataBind();
    }
    //ddCostCen.DataSourceID = "DS_CostCentre";
    ddCostCen.Enabled = true;
      
}

As mentioned, because i need the datasource changed based on the reportlevel value selected, i need the datasource selectcommand being assigned a new value in the ReportLevel SelectedIndexChanged event but this gives me a databind error.

Can you please help me find a solution to this problem?

Regards,

Shuja 
Calleigh
Top achievements
Rank 1
 answered on 26 May 2011
1 answer
68 views
I have an radmaskedtextbox in my page and i want only character from a to z and A to Z without é, è, etc.

How I can do this ?
Daniel
Telerik team
 answered on 26 May 2011
5 answers
172 views
Hello,

I am trying to use the treeview in the RadComboBox: http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx?product=combobox

When the user expands a combo item, I need the RadComboBox drop down to expand too.  Seems easy enough to do, but I have a CSS style applied that I would like for it to meet.  It doesn't seem to apply the style initially (maybe because its a custom item template) and so how can I handle?

If the style class doesn't work, then I'm thinking tap into the NodeExpanded event on the TreeView, and adjust the size of the drop down.  Is there a method that says "reevaluate the combo's contents and allow more room"?

Thanks.
Helen
Telerik team
 answered on 26 May 2011
1 answer
58 views
Hi, 
My objective is to create a radgrid based on some parameters. 
I am creating the radgrid on page init().
Now the problem for me is to access the values of the controls(say a value of radio button) on the page after a button click in the page_init().

Please help me in this regard.

Thanks in advance.

Regards,
Vijay
Maria Ilieva
Telerik team
 answered on 26 May 2011
1 answer
154 views
Hi, 

I need to apply generic aggregate functions like sum, min, max or average on ChartSeries. 

The Chart data binding is done by assign series, columns and datasource:

Dim vChartSeries = New ChartSeries("Series 1", ChartSeriesType.Bar)
vChartSeries.YAxisType = ChartYAxisType.Primary
Dim vChartSeries2 = New ChartSeries("Series 2", ChartSeriesType.Bar)
vChartSeries2.YAxisType = ChartYAxisType.Secondary
RadChart2.AddChartSeries(vChartSeries)
RadChart2.AddChartSeries(vChartSeries2)
RadChart2.PlotArea.XAxis.AxisLabel.TextBlock.Text =
"AAA"
RadChart2.PlotArea.YAxis.AxisLabel.TextBlock.Text "BBB"
RadChart2.Series(0).DataYColumn = "value_column_left"
RadChart2.Series(1).DataYColumn = "value_column_right"
RadChart2.PlotArea.XAxis.DataLabelsColumn = "groupby_column"
RadChart2.DataSource = getDataSource()
RadChart2.DataBind()



How can I apply such aggregate functions? Or can it be done during DataBinding, ItemDataBound or DataBound events "by hand"?

Many thanks for some help,
Andreas
Evgenia
Telerik team
 answered on 26 May 2011
2 answers
152 views

Hi I have a radlistview that gets random items from the database, each item has two buttons inside add to wishlist, add to cart.
I wanna do a clientside event to a javascript that triggers an event in codebehind without
reloading the webpage. Each button has two arguments that needs to be posted
back to a code behind event.

I cant use ajaxpanel for the radlistview considering it's getting random items, it wont work because the id value of the index wont be the same after postback. didnt even work when I put the buttons directly inside a radajaxpanel.

What I would like to know what is the best way in with RadControls to do this with javascript AJAX event...

A working sample would be appreciated because I have searched all over the web and in teleriks vast resources but havent been
able to find something that works nor figure it out on my own. this will also trigger a external
ajaxpanel to reload and show the result of the button clicked but thats an easy fix when the rest is solved.

Thanks,

Maria Ilieva
Telerik team
 answered on 26 May 2011
1 answer
278 views
I have an odd question.  I have a radgird that I allow edit and insert here is a sample of a column

<telerik:GridTemplateColumn HeaderText="Description" SortExpression="Description" UniqueName="Description"  >                                                       
      <ItemTemplate>                                                        
               <asp:Label runat="server" ID="lbDescription" Text='<%# Eval("Description")%>'></asp:Label>
      </ItemTemplate>
      <EditItemTemplate>                                                        
              <telerik:RadTextBox ID="tbDescription" Width="300px" TextMode="MultiLine" Text='<%# Eval("Description")%>'
                        runat="server" />
      </EditItemTemplate>
</telerik:GridTemplateColumn>
  The problem is the label "Description:" is aligned vertical center on the RadTextBox.  Is there a way to align it Vertical Top?
Vasil
Telerik team
 answered on 26 May 2011
5 answers
112 views
I have to create a grid like this. Its like loading double grid.
The customer data was loaded in a general grid and the aging details should load inside the main grid as shown in the Gird.
$uren
Top achievements
Rank 1
 answered on 26 May 2011
2 answers
203 views
Hi.
How can i remove edit button for a detailtable with in place mode in a hierarchical grid?
I have found a solution for a grid as follows:

   if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridDataInsertItem)
            {
                radGrid.MasterTableView.GetColumn(columnName).Visible = true;
                foreach (GridDataItem dataItem in radGrid.MasterTableView.Items)
                {
                    (dataItem[columnName].Controls[0]).Visible = false;
                }
            }
            else
                radGrid.MasterTableView.GetColumn(columnName).Visible = false;

but can't find out who to hide the edit button for the detailtable when i have a hierarchical grid with on detail table. Anyone?
Cecilie Nordbø
Top achievements
Rank 1
 answered on 26 May 2011
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
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
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?