Telerik Forums
UI for ASP.NET AJAX Forum
8 answers
201 views
Hello All,

  I exported the telerik grid to excel by using the command below

RadGrid_DetailsView.MasterTableView.ExportToExcel();

I want to set the header on each page that says
"This is the DRAFT Data".

How can I accomplish that.

Thanks.

Daniel
Telerik team
 answered on 18 Jul 2011
1 answer
73 views
Hi,
 I am using two grid and some controls on the page but. Now I am getting a problem on the page and that is if i click on page anywhere than it shows alert to delete record. i am using

  <telerik:GridButtonColumn
                                ConfirmDialogType="RadWindow" ConfirmText="Are you sure you want to delete this record?" ConfirmTitle="System Message" ButtonType="ImageButton"
                                CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                <ItemStyle HorizontalAlign="Center" Width="20px" />
                                <HeaderStyle Width="20px" />
                            </telerik:GridButtonColumn>


as a delete column. Please help me to resolve this problem.

Thanks
Manish.
Andrey
Telerik team
 answered on 18 Jul 2011
4 answers
182 views
Hi forum!

i'm having some trouble making a combobox select an item knowing its value. I've seen demos and documentation and i cloned the examples but its not working for me. I don't know what im doing wrong.

 When i select an item from my combobox1, even in the RadComboBox1_SelectedIndexChanged the selectedIndex is always = -1 so this way i can't know the index of the item and use it for other things.
So to try and selecte an item in the radcombobox2 i go for the value of the item selected in the radcombobox1. This value comes right but when i try RadComboBox2.SelectedIndex = RadComboBox2.FindItemIndexByValue(boletim_id) the index i receive from the find method is -1 and i know that exists an item with the boletim_id value in the radcombobox2 because the datasource in both radcombobox is the same. The same will happen if i try the finditemindexbytext or finditembyvalue or finditembytext.

File Code (ASP)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
  
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
  
<!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>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    </telerik:RadScriptManager>
    <div>
      
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Processos8ConnectionString %>" 
            SelectCommand="SELECT [Sinistrado], [Sinistrado_ID] FROM [Sinistrados]">
        </asp:SqlDataSource>
      
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Processos8ConnectionString %>" 
            SelectCommand="SELECT [Sinistrado_ID], [Sinistro_ID], [Tomador_ID], [Boletim_id] FROM [Boletins]">
        </asp:SqlDataSource>
          
      
    </div>
    <telerik:RadComboBox ID="RadComboBox1" Runat="server" 
        DataSourceID="SqlDataSource1" DataTextField="Sinistrado" 
        DataValueField="Sinistrado_ID" AllowCustomText="True" 
        AutoCompleteSeparator="|" AutoPostBack="True" ItemsPerRequest="20" 
        MarkFirstMatch="True" ShowMoreResultsBox="True" 
        EnableAutomaticLoadOnDemand="True">
    </telerik:RadComboBox>
    <telerik:RadTextBox ID="RadTextBox1" Runat="server">
    </telerik:RadTextBox>
    <telerik:RadTextBox ID="RadTextBox2" Runat="server">
    </telerik:RadTextBox>
    <telerik:RadComboBox ID="RadComboBox2" Runat="server" 
        DataSourceID="SqlDataSource1" DataTextField="Sinistrado" 
        DataValueField="Sinistrado_ID" AllowCustomText="True" 
        AutoCompleteSeparator="|" AutoPostBack="True" ItemsPerRequest="20" 
        MarkFirstMatch="True" ShowMoreResultsBox="True" 
        EnableAutomaticLoadOnDemand="True">
    </telerik:RadComboBox>
    <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" 
            DataSourceID="SqlDataSource2" GridLines="None" 
        AutoGenerateColumns="False">
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
  
<MasterTableView datakeynames="Boletim_id" 
                datasourceid="SqlDataSource2">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
  
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
  
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
  
    <Columns>
        <telerik:GridButtonColumn Text="Select" CommandName="Select" ButtonType="ImageButton" ImageUrl="~/images/select_16_mouse.png">
        </telerik:GridButtonColumn>
        <telerik:GridBoundColumn DataField="Sinistrado_ID" DataType="System.Int32" 
            FilterControlAltText="Filter Sinistrado_ID column" HeaderText="Sinistrado_ID" 
            SortExpression="Sinistrado_ID" UniqueName="Sinistrado_ID">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Sinistro_ID" DataType="System.Int32" 
            FilterControlAltText="Filter Sinistro_ID column" HeaderText="Sinistro_ID" 
            SortExpression="Sinistro_ID" UniqueName="Sinistro_ID">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Tomador_ID" DataType="System.Int32" 
            FilterControlAltText="Filter Tomador_ID column" HeaderText="Tomador_ID" 
            SortExpression="Tomador_ID" UniqueName="Tomador_ID">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Boletim_id" DataType="System.Int32" 
            FilterControlAltText="Filter Boletim_id column" HeaderText="Boletim_id" 
            ReadOnly="True" SortExpression="Boletim_id" UniqueName="Boletim_id">
        </telerik:GridBoundColumn>
    </Columns>
  
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
  
        <ClientSettings>
            <Selecting AllowRowSelect="True" />
        </ClientSettings>
  
<FilterMenu EnableImageSprites="False"></FilterMenu>
        </telerik:RadGrid>
      
    </form>
</body>
</html>

File Code(VB.NET)
Imports Telerik.Web.UI
Imports System.IO
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Data
Imports System.Net
Partial Class _Default
    Inherits System.Web.UI.Page
  
    Protected Sub RadComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles RadComboBox1.SelectedIndexChanged
        SqlDataSource2.SelectCommand = "SELECT [Sinistrado_ID], [Sinistro_ID], [Tomador_ID], [Boletim_id] FROM [Boletins] WHERE SINISTRADO_ID = " & RadComboBox1.SelectedValue
        RadGrid1.DataBind()
        RadComboBox1.SelectedIndex = RadComboBox1.SelectedIndex
    End Sub
  
    Protected Sub RadGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.SelectedIndexChanged
        Dim boletim_id As String = DirectCast(RadGrid1.SelectedItems.Item(0), GridDataItem).Cells(6).Text.ToString
        RadTextBox1.Text = DirectCast(RadGrid1.SelectedItems.Item(0), GridDataItem).Cells(5).Text.ToString
        RadTextBox2.Text = DirectCast(RadGrid1.SelectedItems.Item(0), GridDataItem).Cells(4).Text.ToString
        Dim x As Integer = RadComboBox2.FindItemIndexByValue(boletim_id)
        'Dim z As Integer = RadComboBox1.SelectedItem.Index
        RadComboBox1.Text = ""
        RadComboBox1.SelectedValue = ""
        RadComboBox2.SelectedIndex = RadComboBox2.FindItemIndexByValue(boletim_id)
        RadComboBox2.SelectedIndex = RadComboBox1.SelectedItem.Index
    End Sub
End Class


Many Thanks,
FEST
Dimitar Terziev
Telerik team
 answered on 18 Jul 2011
4 answers
168 views
Hi,

I want to create a grid as attached in the image.
As you can see I have rowspan set to first 2 columns of the grid. I am setting the rowspan by comparing the column value in row and previous row, and by combining the rows. So i am able to achieve the first part.
columns country, currency, col3,col4,col5 are declared statically in aspx page. so far so good.
I have random number of contact columns (in turn divided into 3 columns). I want to add these columns to Grid in code-behind. I checd in the documentation of grid and it says

RadGrid does not support mixing declarative grid columns with grid columns added dynamically at runtime. You should either create all the columns in the grid programmatically, or else define them all in the ASPX file.

How to further build the Grid?

Thanks
Teldev




Iana Tsolova
Telerik team
 answered on 18 Jul 2011
2 answers
100 views

Hi,

 

I am getting the formatting problem in RADGRID. the header columns are not getting aligned with the code.

Kindly, see the below code and suggest a solution:

 <rad:radgrid id="rgvCRSummary" runat="server" gridlines="both" height="115px" isdynamic="False"
                                                    skin="Master" skinspath="~/App_Themes/MasterTheme/Skins" width="100%">
 <HeaderStyle CssClass="Grid_headerHP" />
 <ItemStyle CssClass="Grid_ItemHP"  />
<AlternatingItemStyle CssClass="Grid_ItemHP"  /> 
<SelectedItemStyle  CssClass="Grid_SelectedHP" /> 
<MasterTableView EnableColumnsViewState="true" TableLayout="Fixed" Width="100%">
<Columns>
<rad:GridBoundColumn DataField="heading" UniqueName="heading" DataFormatString = "<nobr>{0}</nobr>"><HeaderStyle Width="30%" /></rad:GridBoundColumn>
<rad:GridBoundColumn DataField="sales_pos" HeaderText="<nobr>Sales Position</nobr>" UniqueName="sales_pos" DataFormatString = "<nobr>{0}</nobr>"></rad:GridBoundColumn>
<rad:GridBoundColumn DataField="Geo" HeaderText="Geography" UniqueName="Geo" DataFormatString = "<nobr>{0}</nobr>"></rad:GridBoundColumn>
<rad:GridBoundColumn DataField="Acc" HeaderText="Account" UniqueName="Acc" DataFormatString = "<nobr>{0}</nobr>"></rad:GridBoundColumn>
<rad:GridBoundColumn DataField="Presc" HeaderText="Prescriber" UniqueName="Presc" DataFormatString = "<nobr>{0}</nobr>"></rad:GridBoundColumn>
</Columns>
</MasterTableView>
</rad:radgrid>

Please find the attached file as my web page having RadGrid.
I am using the  radgrid version 5.1.1.0 and IE8 as my web browser.
Please suggest me how can we resolve with this misalignment of column with this version.

Thanks,
Manoj Singh

 

Iana Tsolova
Telerik team
 answered on 18 Jul 2011
4 answers
850 views

Hi ,

My asp.net page contains a radscheduler , whenever I view this page I get the following error.

System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.

   at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)

   at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)

   at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
   at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo)

   at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType)
   at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Craig Wallace
Top achievements
Rank 1
 answered on 18 Jul 2011
1 answer
95 views
Hi,

Is it possible to export two radgrid in 1 pdf /excel file?


Thanks,
Bermo
Princy
Top achievements
Rank 2
 answered on 18 Jul 2011
1 answer
197 views
Hello All,

I have a RadFileExplorer in our application which is created dynamically. The grid has two bound columns for which we have to enable column sorting. I have registered the GridSortCommandEventHandler while creating the Grid but the grid is not triggering the Sort event.

radFileExplorer.Grid.ID = radGridViewName;

radFileExplorer.Grid.AllowSorting = true;  
radFileExplorer.Grid.ItemDataBound += new GridItemEventHandler(radFileExplorer_ItemDataBound);  
radFileExplorer.Grid.SortCommand += new GridSortCommandEventHandler(radFileExplorer_SortCommand);  
radFileExplorer.TreeView.NodeClick += new RadTreeViewEventHandler(treeView_NodeClick);

Below is the code written for radFileExplorer_SortCommand event. The below event is not getting invoked on click of the column header.

void

radFileExplorer_SortCommand(object sender, GridSortCommandEventArgs e)  

{

string sortDir = "ASC";  
DataView dv = new DataView(Documents);  
string viewStateKey = "sortDirection" + e.SortExpression;  
if (ViewState[viewStateKey] != null)  

{
sortDir = ((string)ViewState[viewStateKey] == "ASC") ? "DESC" : "ASC";  
}

ViewState[viewStateKey] = sortDir;
dv.Sort = e.SortExpression + 

" " + sortDir;  
SortExpression = dv.Sort; 
GridView docListGrid = (GridView)this.FindControl(radGridViewName);  
if (docListGrid != null)  
{

docListGrid.DataSource = dv;

docListGrid.DataBind();

}

}

This is quite urgent and any help would be appriciated.

Many thanks in advance.

Regards
Rajeev



Dobromir
Telerik team
 answered on 18 Jul 2011
1 answer
66 views
Hi


how to create the rad combo box dynamically in java script coding
and also date picker  control

Please let me know the information and steps regarding this

Thank you for your help!
Shinu
Top achievements
Rank 2
 answered on 18 Jul 2011
1 answer
106 views
Hi,

I'm currently having the problem, that my "add new record" button isn't showing in my detailgrid..
Even so, my grid does not show the expandbutton, to open the detailgrid.
I'm currently aware that there are no records to retrieve from the database, but however it must show the text "No items to display"

I included a screenshot for more information.

This is the code:
public void Page_Load(object sender, EventArgs e)
{
    // Get Total ProcessTemplates
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MSCBE.DashboardConnectionString"].ConnectionString);
    SqlCommand cmd = new SqlCommand("SELECT COUNT(ProcessTemplate_id) AS total FROM ProcessTemplate", conn);
    conn.Open();
    int intTotalProcessTemplates = Convert.ToInt32(cmd.ExecuteScalar());
    conn.Close();
    // Create grids
    RadGrid[] GridName = new RadGrid[intTotalProcessTemplates];
     
    for (int i = 0; i < intTotalProcessTemplates; ++i)
    {
        // Create mastertable
        GridName[i] = new RadGrid();
        GridName[i].DataSource = GetDataTables.GetDataTable("SELECT * FROM ProcessTemplate WHERE ProcessTemplate_id = " + (i + 1));
        GridName[i].MasterTableView.DataKeyNames = new string[] { "ProcessTemplate_id" };
        GridName[i].Skin = "Black";
        GridName[i].AutoGenerateColumns = false;
        GridName[i].AllowPaging = true;
        GridName[i].ShowStatusBar = true;
        // Columns create
        GridName[i].MasterTableView.Columns.Add(CreateGridColumn("Process name", "Name", 10.0));
        GridName[i].MasterTableView.Columns.Add(CreateGridColumn("Process description", "Description", 80.0));
        GridName[i].MasterTableView.Columns.Add(CreateGridColumn("Parent", "Parent", 10.0));
        // Create detail table
        GridTableView tableViewStartProcesses = new GridTableView(GridName[i]);
        tableViewStartProcesses.Name = "DetailTable_" + i;
        tableViewStartProcesses.DataKeyNames = new string[] { "Process_id" };
        tableViewStartProcesses.AutoGenerateColumns = false;
        tableViewStartProcesses.AllowPaging = true;
        tableViewStartProcesses.ShowFooter = true;
        tableViewStartProcesses.ShowHeadersWhenNoRecords = true;
        tableViewStartProcesses.CommandItemDisplay = GridCommandItemDisplay.Top;
        
        // Reset Counter
        //Count[i] = new int();
        int counter = 0;
        CountItems countitem = new CountItems();
        countitem.id = i;
        // Fix result from stored proc: GetAllProcessesAndSteps_SP
        DataSet _dataset = BLProcessesAndSteps.GetAllProcessesAndSteps((i + 1));
        if (_dataset.Tables.Count > 0)
        {
            var query = from r in _dataset.Tables[0].AsEnumerable()
                        where r.Field<decimal>("templateid") == (i + 1) // DO NOT REMOVE FROM STORED PROC                            
                        select r;
            // Get total columns
            int TotalColumns = query.AsDataView().Table.Columns.Count;
              
            GridBoundColumn[] gbcColumnName = new GridBoundColumn[TotalColumns];
              
            // Loop trough header items
            for (int j = 0; j < TotalColumns; ++j)
            {
                // Create detailcolumns
                gbcColumnName[j] = new GridBoundColumn();
                gbcColumnName[j].ReadOnly = true;
                string strData = query.AsDataView().Table.Columns[j].ToString();
                if (strData == "Process_id" || strData == "templateId" || strData == "ProcessName")
                {
                    gbcColumnName[j].Visible = false;
                    gbcColumnName[j].ReadOnly = true;
                }
                string strQuery = "SELECT DISTINCT(CriteriaType.Name), CriteriaType.CriteriaType_id, Process.ProcessTemplate_id FROM CriteriaType INNER JOIN CriteriaValue ON CriteriaType.CriteriaType_id = CriteriaValue.CriteriaType_id INNER JOIN Process ON CriteriaValue.Process_id = Process.Process_id WHERE Process.ProcessTemplate_id = " + (i + 1);
                DataTable dtCriteriaTypes = GetDataTables.GetDataTable(strQuery);
                string[] strValues = new string[dtCriteriaTypes.AsDataView().Table.Rows.Count];
                  
                 
                for (int k = 0; k < dtCriteriaTypes.AsDataView().Table.Rows.Count; ++k)
                {
                    strValues[k] = dtCriteriaTypes.AsDataView().Table.Rows[k]["Name"].ToString();
                    if (strData == strValues[k])
                    {
                        gbcColumnName[j].ReadOnly = false ;
                        counter++;
                    }
                }
                countitem.count=counter;
                  
                gbcColumnName[j].HeaderText = strData;
                gbcColumnName[j].DataField = strData;
                // Add detailcolumns
                tableViewStartProcesses.Columns.Add(gbcColumnName[j]);
            }
            Count.Add(countitem);
            // Add Details to table
            GridName[i].MasterTableView.DetailTables.Add(tableViewStartProcesses);
            // Rebind
            tableViewStartProcesses.DataSource = query.AsDataView();
        }
        // Add to placeholder
        this.StartProcessPlaceHolder.Controls.Add(GridName[i]);
        // Events
        GridName[i].InsertCommand += new GridCommandEventHandler(OverviewProcess_InsertCommand);
    }
Shinu
Top achievements
Rank 2
 answered on 18 Jul 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?