Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
335 views
Hi,
I am using RadGrid from telerik version 2012.1.215.40.

I have two methods RadGrid_NeedDataSource and Page_Prerender event

I am trying to hide AddNewrecordButton based on user permissions

protected override void OnPreRender(EventArgs e)
       {
           try
           {
             
               //Hide controls on the page based on permission
              //Code to hide control
              // code to hide RadGrid AddNewRecordButton
                RadGrid1.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;                  
            }
               base.OnPreRender(e);
           }
           catch (Exception ex)
           {
               HandleException(ex, ErrorControl);
           }
       }

This code doesn't hide the AddNewRecordButton from the grid.
But if i write the same code in RadGrid_NeedsdataSource event, it works. I also tried radGrid_PreRender event but that also not working.
If i add RadGrid.Rebind() method in prerender event, it works. But it fires the NeedsdataSource event again that i don't want.
All my code to hide/show controls based on the permissions is inside the PreRender event. So i don't want to use NeedsDataSource event just for hide/show of Add new record button.
Please suggest what is wrong with the PreRender event.
Gaurav
Top achievements
Rank 1
 answered on 03 Jul 2012
5 answers
240 views

Hi Team,
            1) We are using RadGrid in our application, we plan to use the In-built functionality from Telerik Radgrid for Exporting the Grid data to Word document and PDF format document. We have Grid data, and Chart Image for the corresponding Grid Data which we displaying outside the Grid. I have attached the Screenshot of my application, I need to populate the Chart Image along with the Grid Data to word document and pdf document while export.  (attached file Name: Application_ScreenShot.JPG)

            2) Also I would like to know that Isn't it possible to export the Grid data with skin(font color,fort size,font family) to Word and Excel and PDF format.

            3) While I tried to Export into PDF format, the Grid Data is not populating properly. Kindly find the attached file for get me.(attached File Name for reference: PDF.JPG)

Please give me any possible solution on this ASAP.

Thanks
Alexis


Sreekanth
Top achievements
Rank 1
 answered on 03 Jul 2012
0 answers
121 views
Dear Telerik Team

i have a very  basic problem, i have just added a  button on the group header in the pre-render event. following is the code.
when click the button this dont called the ItemCommand event for the grid. Please suggest the true way for calling the event.

protected void Item_PreRender(object sender, EventArgs e)
        {
            string text = ((GridGroupHeaderItem)sender).DataCell.Text;
 
            for (int i = 4; i < ((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns.Length; i++)
            {
                TableCell cell = new TableCell();
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "TESTDESC")
                {
                    cell.Text = text.Trim().Replace(": ", "");
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "Name")
                {
                    cell.Text = "Name";
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "ToTalScores")
                {
                    cell.Text = "Total Scores";
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "REPORTINGTIME")
                {
                    cell.Text = "EST Time";
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "MainGroupCollapse")
                {
                    Button ExpandControl = ((GridGroupHeaderItem)sender).Cells[0].Controls[0] as Button;
                    ExpandControl.CssClass = "rgCollapse";
                    cell.CssClass = "MainGroupCollapse";
                    cell.Controls.Add(ExpandControl);
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "DOWNLOAD")
                {
                    LinkButton lnkDownloadBtn = new LinkButton();
                    lnkDownloadBtn.ID = "btnDownload";
                    lnkDownloadBtn.Text = "Download/Print";
                    lnkDownloadBtn.CommandName = "DownloadAndPrint";
                    lnkDownloadBtn.CssClass = "DownloadAndPrint";
                    cell.CssClass = "DownloadAndPrintCell";
                    cell.Controls.Add(lnkDownloadBtn);
                }
                if (((GridGroupHeaderItem)sender).OwnerTableView.RenderColumns[i].UniqueName == "LeftSide")
                {
                    cell.CssClass = "LeftRightMargin";
                }
                ((GridGroupHeaderItem)sender).Cells.Add(cell);
            }
        }


protected void RadGridTest_ItemCommand(object source, GridCommandEventArgs e)
{
   GridGroupHeaderItem Item2 = e.Item as GridGroupHeaderItem;
   if (Item2 is GridGroupHeaderItem)
            {
                if (e.CommandName.Equals("DownloadAndPrint"))
                {
                     //call custom methods
                    //RenderReport(TestDateTreeView.SelectedNode.Value, "Chem");
                }
            }            
}


Many thanks
Asim Jabbar

Asim
Top achievements
Rank 1
 asked on 03 Jul 2012
3 answers
233 views
Hi,
I have a 3 level hierarchical grid.It is populated programatically (i.e. through 'DetailTableDataBind')

Each row in the middle-level grid has a hyperlink, which if pressed causes a dialog to be displayed (through RadWindowManager).

When the dialog is closed (by clicking 'Save'), the dialog closed, and calls a 'refreshGrid' function in the parent.

The 'refreshGrid' then does a 'ajaxRequest("RebindAndNavigate")'.

All pretty standard stuff, except it doesn't seem to refresh the contents of the 3rd level grid.

Am I missing something- does the rebind refresh all displayed 'programmatic-populated' children tables?

Cheers,
Steve


Jayesh Goyani
Top achievements
Rank 2
 answered on 03 Jul 2012
2 answers
118 views
Hi Team,
I have a radgrid which I want to refresh when File Save Dialogue box is closed.

This is my code behind.

protected void btnPayment_Click(object sender, EventArgs e)
{
   try
    {
             // do some stuff...
           
           // This code below opens the Save File Dialogue box ..
 
 String FilePath = Server.MapPath(".\\GiroPayments\\" + FileName + "");
 System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
 response.ClearContent();
 response.Clear();
 response.ContentType = "text/plain";
 response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
 response.TransmitFile(FilePath);
 response.Flush();
 response.End();
 
 rgGiroPayments.Rebind();   
    }
   catch() {}
}


If I comment this code to open save file dailogue box, grid gets refreshed. There is some prob with that code..
Could you help me out ?

Thanks,
Lok..
Lokesh
Top achievements
Rank 1
 answered on 03 Jul 2012
1 answer
102 views
I have a RadAjaxManager, which should update a label on click of a button (simplest of tasks I assume.)
<telerik:RadAjaxLoadingPanel ID="AjaxLoadingPanel1" runat="server" Height="75px" Width="75px">

<asp:Label runat="server" ID="lblTest" Text="appears here"/><br/>
<asp:Button runat="server" OnClick="btnTest_OnClick" ID="btnTest" Text="Test"/>
        <telerik:RadAjaxManager runat="server" ID="AjaxManager1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btnTest">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="lblTest" LoadingPanelID="AjaxLoadingPanel1"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

and in the code behing

        protected void btnTest_OnClick(object sender, EventArgs e)
        {
            lblTest.Text = "12324";
        }

No matther how many times I try, the label could not get updated.
I've used fiddler and part of the response is something like below:

31|updatePanel|lblTestPanel|<span id="lblTest">12324</span>|53|updatePanel|AjaxManager1SU|<span id="AjaxManager1" style="display:none;"></span>


Am I missing anything?



Coax
Top achievements
Rank 1
 answered on 03 Jul 2012
2 answers
200 views
I am using an AutoCompleteExtender for a search textbox and the results go far enough down the page to interfere with a RadGrid. It appears that the z-index of the header on the RadGrid is too high as my autocomplete results appear under the header but over the rest of the RadGrid. Any ideas on how to lay my autocomplete results over the RadGrid header?
License
Top achievements
Rank 1
 answered on 02 Jul 2012
3 answers
119 views

My site has the need to close a menu if the mouse leaves the window (its very close to the left edge, so its easily left open).

As we have multiple menu's on our page, there is the unlikely possibility that more tha none could be left open, so I really wanted to use a jQuery selector to find all menu controls, and fire its close() method when the mouse leaves the window.

I got to this :

 

$telerik.$(document).mouseleave(

    function () {
        $('.RadMenu').close();
        }
);

 


However, the $('.RadMenu').close(); doesn't work - erroring that close() isn't supported. if I go through the results from $('.RadMenu'), they do seem to be the correct elements being returned (HTMLDiv objects).

Can anyone help?

Thanks,

Andrew

Nona
Top achievements
Rank 1
 answered on 02 Jul 2012
1 answer
234 views
Team,

I need to update Header Template controls data from code behind during Item_Databound. Suggest possible solution.

ASPX
-------

                                                    <telerik:GridTemplateColumn UniqueName="Leg" HeaderText="Leg1">
                                                        <HeaderTemplate>
                                                            <asp:HiddenField ID="hdnLeg1" runat="server" />
                                                            <asp:Label ID="lbLeg1" Text="" runat="server" />
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <asp:DropDownList ID="DropDownList1" runat="server">
                                                            </asp:DropDownList>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn UniqueName="Leg" HeaderText="Leg1">
                                                        <HeaderTemplate>
                                                            <asp:HiddenField ID="hdnLeg2" runat="server" />
                                                            <asp:Label ID="lbLeg2" Text="" runat="server" />
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <asp:DropDownList ID="DropDownList2" runat="server">
                                                            </asp:DropDownList>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
.............

ASPX.CS

// Code must update each Hidden variables with it's ID and Label Text for Grid Column Header
 if (e.Item is GridHeaderItem)
                {
                    int PreviousLegIDIndex = 0;
                    int counter = 0;
                    foreach (GridHeaderItem headerItem in dgPassanger.MasterTableView.GetItems(GridItemType.Header))
                    {
                        counter = 0;
                        foreach (var Leg in Log.Legs)
                        {
                            counter++;
                            if (counter > PreviousLegIDIndex)
                            {
                                foreach (var headerControl in headerItem["Leg"].Controls)
                                {
                                    PreviousLegIDIndex = counter;
                                    if (headerControl.GetType() == typeof(Label))
                                    {
                                        Label lbHeader = (Label)headerControl;
                                        lbHeader.Text = tripLeg.POLegsDescription;
                                    }
                                    if (headerControl.GetType() == typeof(HiddenField))
                                    {
                                        HiddenField hdnHeader = (HiddenField)headerControl;
                                        hdnHeader.Value = tripLeg.LegID.ToString();
                                    }
                                }
                                break;
                            }
                        }
                    }
                }

Jayesh Goyani
Top achievements
Rank 2
 answered on 02 Jul 2012
0 answers
72 views
I am dynamically generating a list of columns for a radgrid and everything there is fine the issue that occurs when I'm trying to convert a GridBoundcColumn to a GridDropDownListColumnEditor on the CreateColumnEditor

I was wondering if it was possible to add to add a drop down list, combo box or even a lookup button to the edit template on the radgrid
*Note the datatable is just for testing the columns are coming from a database

Public Property DT As DataTable
     Get
         Return ViewState("DT")
     End Get
     Set(ByVal value As DataTable)
         ViewState("DT") = value
     End Set
 End Property
 
 
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     If Not Page.IsPostBack Then
         AddEditColumn()
         DT = GetData()
     End If
 End Sub
 
 
 Private Sub RadGrid1_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
     Me.RadGrid1.DataSource = DT
 End Sub
 
 Sub AddEditColumn()
     If Not RadGrid1.Columns.Contains("GridEditCommandColumn") Then
         Dim EditCol As New GridEditCommandColumn
         RadGrid1.Columns.Add(EditCol)
     End If
 End Sub
 
 Private Sub RadGrid1_CreateColumnEditor(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCreateColumnEditorEventArgs) Handles RadGrid1.CreateColumnEditor
     If (TypeOf e.Column Is GridBoundColumn) Then
         If (CType(e.Column, GridBoundColumn).DataField = "Customer") Then
             e.ColumnEditor = New GridTextBoxColumnEditor
             'e.ColumnEditor.ContainerControl.Controls
         ElseIf (CType(e.Column, GridBoundColumn).DataField = "CustomerType") Then
             'e.ColumnEditor = New GridDropDownListColumnEditor
         End If
     End If
 End Sub
 
 Private Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
     If (TypeOf e.Item Is GridDataItem) Then
         Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
 
     ElseIf (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
         Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
 
     End If
 End Sub
 
 Private Function GetData()
     Dim datatable As New DataTable
     datatable.Columns.Add("Customer", GetType(String))
 
     datatable.Columns.Add("CustomerType", GetType(String))
     '********************************************************
     'CustomerType is the Column that needs to be a drop down.     
    
'********************************************************
 
     datatable.Columns.Add("QtyOrd", GetType(Integer))
     datatable.Columns.Add("Date1", GetType(Date))
     datatable.Columns.Add("Date2", GetType(Date))
     datatable.Columns.Add("OnTime", GetType(Boolean))
 
     datatable.Rows.Add({("A&A Beef"), ("WHOL"), 1, DateTime.Now, DateTime.Now, False})
     datatable.Rows.Add({("Vegmart"), ("RET"), 8, DateTime.Now, DateTime.Now, False})
 
     Return datatable
 End Function
Andy
Top achievements
Rank 1
 asked on 02 Jul 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?