Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
197 views
Hi :)

I tried to implement a pivot for radgrid ... And I have some problems ....

I'd like my line's name are not the field of my database (for example, now I have "db_name" and I want "Name").
I'd like to make a header for all the grid with "User Informations"

This is my code :

ASP :

<telerik:RadGrid runat="server" ID="view" 
  ShowStatusBar="true"
  AutoGenerateColumns="false"
  Visible="false">
   
  <ClientSettings>
     <Selecting AllowRowSelect="True"/>
  </ClientSettings>
 
  <GroupingSettings CaseSensitive="false" />
     
  <MasterTableView  ShowHeadersWhenNoRecords="true" DataKeyNames="Id"  ClientDataKeyNames="Id">
 
  <Columns>
 
       <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="User Name"
       AutoPostBackOnFilter="true"  Visible="true">
       </telerik:GridBoundColumn>
 
       <telerik:GridBoundColumn DataField="Phone" UniqueName="Phone" HeaderText="User Phone"
       AutoPostBackOnFilter="true"  Visible="true">
       </telerik:GridBoundColumn>
 
       <telerik:GridBoundColumn DataField="Email" UniqueName="Email" HeaderText="User Email"
       AutoPostBackOnFilter="true"  Visible="true">
       </telerik:GridBoundColumn>
  </Columns>
  </MasterTableView>   
</telerik:RadGrid>
 
<br />
 
<telerik:RadGrid runat="server" ID="view2" 
  ShowStatusBar="true"
  Visible="true">
   
  <ClientSettings>
     <Selecting AllowRowSelect="True"/>
  </ClientSettings>
 
  <GroupingSettings CaseSensitive="false" />
     
  <MasterTableView  ShowHeader="false" >
   
  </MasterTableView>
  </telerik:RadGrid>


C#

protected void Page_Load(object sender, EventArgs e)
 {
            if (!Page.IsPostBack)
            {
                BindGridView();
            }
 
 }
 
 
        private DataTable PivotTable(DataTable origTable)
        {
 
            DataTable newTable = new DataTable();
            DataRow dr = null;
            //Add Columns to new Table
            for (int i = 0; i <= origTable.Rows.Count; i++)
            {
                newTable.Columns.Add(new DataColumn(origTable.Columns[i].ColumnName, typeof(String)));
            }
 
            //Execute the Pivot Method
            for (int cols = 0; cols < origTable.Columns.Count; cols++)
            {
                dr = newTable.NewRow();
                for (int rows = 0; rows < origTable.Rows.Count; rows++)
                {
                    if (rows < origTable.Columns.Count)
                    {
                        dr[0] = origTable.Columns[cols].ColumnName; // Add the Column Name in the first Column
                        dr[rows + 1] = origTable.Rows[rows][cols];
                    }
                }
                newTable.Rows.Add(dr); //add the DataRow to the new Table rows collection
            }
            return newTable;
        }
 
        private void BindGridView()
        {
            String str = Request.RawUrl;
            if (!IsPostBack)
            {
                if (str.Contains("?a"))
                {
                    Int32 url_id = Convert.ToInt32(Request.Params["a"]);
                    user_id = url_id;
                    DataTable dt = new DataTable();
                    SqlConnection cn = new SqlConnection("");
                    SqlCommand cmd = new SqlCommand("user_data", cn);
                    cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.Int));
                    cmd.Parameters["@id"].Value = url_id;
                    cmd.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter sqlDa = new SqlDataAdapter(cmd);
                    sqlDa.Fill(dt);
 
                    try
                    {
                        cn.Open();
                        if (dt.Rows.Count > 0)
                        {
                            //Bind the First GridView with the original data from the DataTable
                            view.DataSource = dt;
                            view.DataBind();
 
                            //Pivot the Original data from the DataTable by calling the
                            //method PivotTable and pass the dt as the parameter
 
                            DataTable pivotedTable = PivotTable(dt);
                            view2.DataSource = pivotedTable;
                            view2.DataBind();
                        }
                    }
 
                    catch (SqlException ex)
                    {
                        //...
                    }
                    finally
                    {
                        if (cn.State != ConnectionState.Closed)
                        {
                            cn.Close();
                            cmd.Parameters.Clear();
                        }
                    }
                }
            }
        }

Thanks for the help :)
Viktor Tachev
Telerik team
 answered on 18 Aug 2015
7 answers
139 views
    Hi,

I am trying to create a add controls dynamically from the server side in Form template. I am able to create controls and display the controls in Formtemplate but i couldnt find controls in the server side to the values from controls.

Add Controls code sample

 

 

 

Protected Sub rdGridUDFRule_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rdGridUDFRule.ItemDataBound 
    
If TypeOf e.Item Is Telerik.Web.UI.GridEditFormItem And e.Item.IsInEditMode Then 
    
    
    
If e.Item.OwnerTableView.IsItemInserted Then 
    
    
    
'item is about to be inserted 
    
    
    
For Each editItem As Telerik.Web.UI.GridEditFormItem In rdGridUDFRule.MasterTableView.GetItems(Telerik.Web.UI.GridItemType.EditFormItem) 
    
If (editItem.IsInEditMode) Then 
    
    
    
Dim plcHolder As HtmlTableCell = DirectCast(editITem.FindControl("placeHolderRadGridFormTemplate"), HtmlTableCell) 
    
    
Dim objDynamicTxt As New TextBox 
    
objDynamicTxt.ID = "DynamicControl"  
objDynamicTxt.MaxLength = intLength 
    
plcHolder.Controls.Add(objDynamicTxt) 
    
    
End If 
    
    
    
Next 
    
    
    
Else 
    
    
    
'item is about to be edited 
    
    
    
Dim editedItem As Telerik.Web.UI.GridEditableItem = TryCast(e.Item, Telerik.Web.UI.GridEditableItem) 
    
End If 
    
    
    
End If 
    
    
    
End Sub 

 

 

Retrieve Dynamic control values from server side sample code

 

Protected Sub RadGrid1_UpdateCommand(ByVal sender As Object, ByVal e As GridCommandEventArgs) Handles rdGridUDFRule.UpdateCommand 
        If (e.CommandName = RadGrid.UpdateCommandName) Then 
For Each editItem As Telerik.Web.UI.GridEditFormItem In rdGridUDFRule.MasterTableView.GetItems(Telerik.Web.UI.GridItemType.EditFormItem) 
                If (editItem.IsInEditMode) Then 
                    Dim plcHolder As HtmlTableCell = DirectCast(editITem.FindControl("placeHolderRadGridFormTemplate"), HtmlTableCell) 
Dim objDynamicTxt As TextBox = DirectCast(plcHolder.FindControl("DynamicControl"
               '******************************* THE objDynamicTxt RETURN NOTHING *******************************
                End If 
            Next 
        End If 
    End Sub


The Couldnt find the controls, but it is available in the FormTemplate while trying to click on the add new record.

Please let me know in which event the dynamic controls should be created

Thanks
Prabhu

Viktor Tachev
Telerik team
 answered on 18 Aug 2015
4 answers
377 views

I am creating a Dynamically built RadGrid. I have to do so because I am generating columns based on how many dates my sql query returns. I am placing the specific dates as header column groups. Under each date I am trying to create a dropdowncolumn that has a different datasource than the radGrid.
The problem is creating it dynamically. I thought about using an item template but how could I place a dropdown in the item template for each drop down that i need to create, which is two per date.  
How do i bind the datasource for the DropDownColumn from code behind when the entire grid is dynamically built.


for (int t = 0; t < datecount; t++)
        {
            int utacount = Convert.ToInt32(getDrill.Rows[t][3].ToString());

            for (int p = 0; p < datecount; p++)
            {

                GridDropDownColumn ddc = new GridDropDownColumn();

                int b = p + 1;

                ddc.UniqueName = "ddc" + p + s;
                if (p - 1 < utacount)
                {
                    string name = "uta" + p + s;
                    ddc.ColumnGroupName = name;
                    //ddc.DataField = "strStatus";
                    //ddc.ListTextField = "strStatus";
                    ////GridEditableItem editedItem = ddc as GridEditableItem;
                    ////GridEditManager editman = editedItem.EditManager;
                    ////GridDropDownColumnEditor editor = editman.GetColumnEditor(name) as GridDropDownColumnEditor;
                    ////editor.DataSource = getDrill;
                    ////editor.DataBind();

                }
                grid.MasterTableView.Columns.Add(ddc);
            }

            s++;
        }

Viktor Tachev
Telerik team
 answered on 18 Aug 2015
6 answers
1.2K+ views
I am trying to set the column width in the code behind and can not figure out how to do this.  My aspx looks like:


<
telerik:RadGrid ID="RadGrid1" AllowMultiRowSelection="True" runat="server" AutoGenerateColumns="False" GridLines="None" >

 

<

 

MasterTableView >

 

 

 

<Columns>

 

 

 

<telerik:GridBoundColumn DataField="INVOICE" UniqueName="INVOICE"

 

 

HeaderText="Invoice">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn DataField="DATE" UniqueName="DATE" HeaderText="Date">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn DataField="BOL" UniqueName="BOL" HeaderText="BOL">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn DataField="PO" UniqueName="PO" HeaderText="PO">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn DataField="POHIDE" UniqueName="POHIDE" Visible="false"

 

 

HeaderText="PO Hide" >

 

 

 

</telerik:GridBoundColumn>

 

 

 

</Columns>

 

</

 

MasterTableView>

 

 

 

<ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="True" >

 

 

 

<Selecting AllowRowSelect="True" />

 

 

 

</ClientSettings>

 

 

 

</telerik:RadGrid>

I have tried using the RadGrid1_ColumnCreated event but no luck.  How do I change the column width at binding time?

Thanks

John

 

Frank
Top achievements
Rank 1
 answered on 18 Aug 2015
2 answers
340 views

Hi,

Is there a way to disable the RadGrid filter TextBox while keeping the filter button active and visible?  I'm using the button as a combo box and no longer need the TextBox.  Thanks for your help!

Brian
Top achievements
Rank 2
Iron
 answered on 18 Aug 2015
1 answer
54 views

Hi,

      I am Unable to export image of RadHtmlcHart in ie 9 [ Compatibility mode ] using RadClientExportManager. Please find the attachment. It works fine for other versions except ie 8 & 9 [ Compatibility mode ] . 

 

Regards,

Chethan Y

 

Dimitar
Telerik team
 answered on 18 Aug 2015
1 answer
77 views
I am using Telerik:RadImageEditor version 2012.3.1016.40  and getting tools for toolbar from XML file. Most of them tools are working fine but facing issues with some below given tools. These tools are not supporting. and getting message "Cound not find the command Export.Please update your command list." on click below given tools. 
1) Export
2) Draw tools (Pencil, Draw Circle, Draw Rectangle and Line).
HTML script:
<telerik:RadImageEditor ID="imgZipLineViewer" runat="server" ToolsFile="~/Config/RadImageEditor.xml" EnableResize="true" CanvasMode="No"> </telerik:RadImageEditor>

XML Script of RadImageEditor.xml:

<root>
  <tools name="FirstToolbar" dockable="true" enabled="true">
    <tool name="Print" togglebutton="true" />
    <tool name="Save" togglebutton="true" />
    <tool name="Export" togglebutton="true" />
    <tool separator="true"/>
    <tool name="Undo" toolstrip="true" />
    <tool name="Redo" toolstrip="true" />
    <tool name="Reset" />
    <tool separator="true"/>
    <tool name="Zoom" toolstrip="true">
      <tool name="Zoom" togglebutton="true"/>
      <tool name="ZoomIn" togglebutton="true" />
      <tool name="ZoomOut" togglebutton="true" />
    </tool>   
    <tool name="Rotate" toolstrip="true">
      <tool name="Rotate" togglebutton="true" />
      <tool name="RotateRight" togglebutton="true" />
      <tool name="RotateLeft" togglebutton="true"  />
    </tool>
    <tool name="RotateRight" togglebutton="true" />
    <tool name="AddText" togglebutton="true" />
    <tool name="Pencil" toolstrip="true">
      <tool name="Pencil" togglebutton="true" />
      <tool name="DrawCircle" togglebutton="true" />
      <tool name="DrawRectangle" togglebutton="true" />
      <tool name="Line" togglebutton="true" />
    </tool>
  </tools>
</root>

So please give the suitable solution for this.
Vessy
Telerik team
 answered on 18 Aug 2015
1 answer
73 views
I have a RadDateInput with the date format of "m/d/yyyy h:mm" and when I submit the value it parses it and tries to store it in this format "2015-12-20-12-30-00" and then I get a format exception. I want to have it store the value the same as the dat format property "m/d/yyyy h:mm".
Maria Ilieva
Telerik team
 answered on 18 Aug 2015
3 answers
90 views

Unfortunately, the Telerik skins don't specify a text color ​for each and every HTML element of the scheduler.

For example, the default styling for the H2 element in the scheduler header seems to be:

.RadScheduler .rsHeader h2 {
    font-size: 15px;
    font-weight: normal;
    line-height: 30px;
    text-indent: 43px;
    height: 30px;
    display: block;
    overflow: hidden;
}

So now the scheduler picks up whatever color for eg. H2 elements is generally specified in the website, which might not be a suitable color for the scheduler at all.​ 

I understand that I can overrule this in a specific website. But I would like a consistent look of the scheduler elements, regardless of the website styles at hand.

Can you please add default coloring to all control elements in the Telerik control skins?

Magdalena
Telerik team
 answered on 18 Aug 2015
8 answers
255 views
I have setup several radgrid webparts and am running into an issue. At first the webparts work fine but after the server restarts on the weekend the webparts cause an error. If I do a repair install of the Telerik webparts, it solves the issue until the next server reboot (or IISReset) What can I do to solve this issue?

Thanks


Error:
System.InvalidOperationException: Telerik.Web.UI.RadWindow with ID='g_78be1aeb_3a1d_4490_9f07_c51834a37899_BindingWindow' was unable to find an embedded skin with the name 'Windows7'. Please, make sure that the skin name is spelled correctly and that you have added a reference to the Telerik.Web.UI.Skins.dll assembly in your project. If you want to use a custom skin, set EnableEmbeddedSkins=false.
at Telerik.Web.SkinRegistrar.GetEmbeddedSkinAttributes(ISkinnableControl control, Type controlType, Boolean designTime)
at Telerik.Web.SkinRegistrar.RegisterCssReferences(ISkinnableControl control)
at Telerik.Web.UI.RadWindow.ControlPreRender()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Maria Ilieva
Telerik team
 answered on 18 Aug 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?