Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
156 views
I have been able to export to csv by adding a button to the CommandItemTemplate, then in server side findong the control and setting registerPostBackControl,
    Protected Sub RadGrid1_ItemCreated1(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
 
 ....
 
                Dim btn_excel As LinkButton = TryCast(item.FindControl("btn_excel"), LinkButton)
 
                ScriptManager.GetCurrent(Page).RegisterPostBackControl(btn_excel)
 
 ....
 
End Sub

When fired this calls the export and fires correctly prompting the user to view or download.

However I have changed this to now appear as an item in the headerContextMenu, when the user clicks on the export option, the same code fires in the same order, however instead of exporting it just rebinds the data to the grid, the function i use is below,

Sub buildExport(ByVal type As String)
       RadGrid1.MasterTableView.Columns.Clear()
 
       Dim boundColumn As GridBoundColumn
 
       For Each column As DataColumn In Datasource.Columns
 
           If GridDataKeyNames <> "" Then
               If Not GridDataKeyNames.Contains(column.ColumnName.ToString()) Then
                   If column.ColumnName.ToString().ToLower().IndexOf("_hidden") < 0 And column.ColumnName.ToString().ToLower().IndexOf("rowclick") < 0 Then
 
                       boundColumn = New GridBoundColumn
                       RadGrid1.MasterTableView.Columns.Add(boundColumn)
 
                       boundColumn.DataField = column.ColumnName
                       boundColumn.HeaderText = column.ColumnName.Replace("_", " ")
                   Else
                       boundColumn = New GridBoundColumn
                       RadGrid1.MasterTableView.Columns.Add(boundColumn)
 
                       boundColumn.DataField = column.ColumnName
                       boundColumn.HeaderText = column.ColumnName
 
                       boundColumn.Visible = False
                   End If
 
               Else
 
               End If
           Else
               If column.ColumnName.ToString().ToLower().IndexOf("_hidden") < 0 And column.ColumnName.ToString().ToLower().IndexOf("rowclick") < 0 Then
 
                   boundColumn = New GridBoundColumn
                   RadGrid1.MasterTableView.Columns.Add(boundColumn)
 
                   boundColumn.DataField = column.ColumnName
                   boundColumn.HeaderText = column.ColumnName.Replace("_", " ").ToLower()
               Else
                   boundColumn = New GridBoundColumn
                   RadGrid1.MasterTableView.Columns.Add(boundColumn)
 
                   boundColumn.DataField = column.ColumnName
                   boundColumn.HeaderText = column.ColumnName.ToLower()
 
                   boundColumn.Visible = False
               End If
           End If
 
 
       Next
 
       RadGrid1.DataSource = Datasource
       RadGrid1.DataBind()
 
       RadGrid1.PageSize = Datasource.Rows.Count()
       RadGrid1.ExportSettings.IgnorePaging = True
 
       Select Case type
           Case "excel"
               RadGrid1.ExportSettings.ExportOnlyData = True
               RadGrid1.MasterTableView.ExportToCSV()
           Case "pdf"
               RadGrid1.ExportSettings.OpenInNewWindow = True
               RadGrid1.MasterTableView.ExportToPdf()
       End Select
 
   End Sub

Like i said boths methods in exporting call the same function, but only the contextItem will work.  I am databinding the grid again as the user may have hidden some columns, so this way all coulmns are provided, also needed to remove the boundColumn.DataFormatString = "<nobr>{0:N}</nobr>"
which is created when the grid is loaded to prevent word wrap.

I create the headerMenuItems in the following way

Private Sub addMenuItem(ByVal sender As Object, ByVal e As System.EventArgs)
 
    Dim menu As RadContextMenu = RadGrid1.HeaderContextMenu
    Dim item As New RadMenuItem
    item.Text = "Save Layout"
    item.Value = "save"
    item.Attributes("ColumnName") = String.Empty
    item.Attributes("TableID") = String.Empty
    menu.Items.Add(item)
    item = New RadMenuItem
    item.Attributes("ColumnName") = String.Empty
    item.Attributes("TableID") = String.Empty
    item.Text = "Export to CSV"
    item.Value = "csv"
    menu.Items.Add(item)
 
End Sub

The save Layout works fine (calls GridSettingsPersister)

Any help would be much appreciated.
mabs
Top achievements
Rank 1
 answered on 22 Sep 2010
0 answers
111 views

Hi,

 

I am facing a problem in bachupdate on the radgrid. I have used the same demo as the following(http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/clienteditbatchupdates/defaultcs.aspx).

On the double-click I am changing the row values still I am getting "No pending changes to be processed" all the time. In the demo when we change the values it gives dashes around the data. But in my case the dashes is not coming.  In my row I am only editing 2 columns. one is textbox and other one is dropdown.

 

Can somebody please help me.
 

Thanks.

Jessy

Jessy Joseph
Top achievements
Rank 1
 asked on 22 Sep 2010
1 answer
72 views
Hi,

While edit (timeline) plan in scheduler control, if there is any text selected then the selected text getting disappear after the edit operation. Even though there is no changes happed in edit. Please see the attachment for the detailed understanding.

We are using Telerik version 2008.3.1125.20

Thanks & regards,
Team

Peter
Telerik team
 answered on 22 Sep 2010
6 answers
3.9K+ views
Hi,

In my current project, I have to display a RadGrid which looks as follows http://www.gouw.ws/RadGridWithCheckBoxes.jpg

The RadGrid with paging has 3 columns as follows:
 - Column Name of type GridBoundColumn which can be sorted.
 - Columns Select1 and Select2 of type GridCheckBoxColumn whose values can be modified by the user.

The RadGrid is used to display a data item which is a collection of 1 string value (Name) and 2 boolean values.

I need to modify the RadGrid to look as follows http://www.gouw.ws/RadGridWithCheckBoxesModified.jpg

1. Instead of displaying the string Select1 and Select2 as the titles of the GridCheckBoxColumn,
    I need to display a CheckBox on each Column title and when it is un/checked then all the
    CheckBoxes in the column on the corresponding page will be automatically un/checked.
2. Depending on the value of Name on each row, I need to selectively make Select1 CheckBox
    or Select2 CheckBox not visible (but not both).

The code is given as follows:

ASPX
<body>  
    <form id="form1" runat="server">  
    <div>  
        <telerik:RadScriptManager ID="radScriptManager" runat="server" />  
        <telerik:RadGrid ID="radGrid" AutoGenerateColumns="false" AllowMultiRowEdit="true" AllowPaging="true" AllowSorting="true" PageSize="10" OnNeedDataSource="radGrid_NeedDataSource" OnPreRender="radGrid_PreRender" runat="server">  
            <ClientSettings>  
                <Scrolling UseStaticHeaders="true" />  
            </ClientSettings>  
            <PagerStyle Mode="NumericPages" />  
            <MasterTableView DataKeyNames="Name" EditMode="InPlace" TableLayout="Fixed">  
                <Columns>  
                    <telerik:GridBoundColumn DataField="Name" DataType="System.String" HeaderText="Name" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" AllowSorting="true" ReadOnly="true" UniqueName="Name" />  
                    <telerik:GridCheckBoxColumn DataField="Select1" DataType="System.Boolean" HeaderText="Select1" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" AllowSorting="false" ReadOnly="false" UniqueName="Select1" />  
                    <telerik:GridCheckBoxColumn DataField="Select2" DataType="System.Boolean" HeaderText="Select2" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" AllowSorting="false" ReadOnly="false" UniqueName="Select2" />  
                </Columns>  
            </MasterTableView>  
        </telerik:RadGrid>      
    </div>  
    </form>  
</body> 

C#
public partial class RadGridWithCheckBoxes : Page  
{  
    private List<Data> _data;  
  
    protected void Page_Load(object sender, EventArgs e)  
    {  
  
        if (!IsPostBack)  
        {  
            this._data = Data.Load();  
            Session["DATA"] = this._data;  
        }  
        else  
        {  
            this._data = (List<Data>)Session["DATA"];  
        }  
    }  
  
    protected void radGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)  
    {  
        this.radGrid.DataSource = this._data;  
    }  
  
    protected void radGrid_PreRender(object sender, System.EventArgs e)  
    {  
        foreach (GridDataItem item in this.radGrid.Items)  
        {  
            item.Edit = true;  
        }  
        this.radGrid.Rebind();  
    }  
}  
  
public class Data  
{  
    public string Name { get; set; }  
    public bool Select1 { get; set; }  
    public bool Select2 { get; set; }  
  
    public Data(string name, bool select1, bool select2)  
    {  
        Name = name;  
        Select1 = select1;  
        Select2 = select2;  
    }  
  
    public static List<Data> Load()  
    {  
        List<Data> data = new List<Data>();  
        for (int i = 0; i < 25; i++)  
        {  
            data.Add(new Data(String.Format("Data{0}", i), false, false));  
        }  
        return data; 
    } 
} 

Can you please show me how to do this?

Regards,
Herman Gouw
 
Tom M
Top achievements
Rank 1
 answered on 22 Sep 2010
1 answer
131 views
I am using the RadUpload control with my ASP.Net form and I have it configured to insert the uploaded files to a SQL database.  This is working perfectly, but the issue is that it also saves the file(s) into the root directory of my application.  Nowhere in my code project does TargetFolder get set....  so my question is, how can I make it stop saving the file to my app directory?  Thanks.
Genady Sergeev
Telerik team
 answered on 22 Sep 2010
2 answers
177 views
Hello
I use e. IsValid = false; in FileUploaded server-side event. But it does not work.
The uploaded image is saving in TargetFolder. Here is my code:

<%@ Page Language="C#" AutoEventWireup="true" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<script runat="server">
  protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
  {
    // here is code for creating and saving thumbnail
    //    ...
 
    e.IsValid = false;    // now we want to discard uploaded image.
                         // But this does not work :(
  } 
</script>
 
<head runat="server">
    <title></title>
</head>
<body>
 
<form id="form1" runat="server">
 
  <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
  </telerik:RadScriptManager>
 
  <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server"
        onfileuploaded="RadAsyncUpload1_FileUploaded" TargetFolder="images/_test">
  </telerik:RadAsyncUpload> 
<asp:Button ID="Button1" runat="server" Text="Button" /> 
 
</form>
</body>
</html>
Genady Sergeev
Telerik team
 answered on 22 Sep 2010
3 answers
380 views
I have a RadGrid with ExportToExcel functionality.  This part is working correctly when simply displaying what's on the grid.  However I'm having two issues with expanding this functionality:

1) If I add a column to my grid that does not have a "DataField" property it does not get exported.  I can work around this by supplying this parameter, but it would be nice if I could just add a column to be exported.

2) When I change the data in the ItemDataBound event, the changes don't come through.  In other words, say the column contains the value 3, and in the ItemDataBound event I change it to 20 (see below for how I am doing that), in the Excel document I still see 3 as the output.  Note that the code does execute without errors, and also if I export to PDF the correct, updated data does come through, only Excel shows the "old" data.

 

protected void RadGridHardware_ItemDataBound(object sender, GridItemEventArgs e)

 

{

 

if (e.Item is GridDataItem)

 

{

 

GridDataItem dataItem = (GridDataItem)e.Item;

 

dataItem[

"Quantity"].Text = "20";

 

}

Any thoughts or ideas?

Daniel
Telerik team
 answered on 22 Sep 2010
3 answers
381 views
Hello,

I'm wonder if I can display the radwindow control in full-screen mode. 
I can maximize the radwindow control to become as FullScreen1.jpg image (attached), but the required situation is to display the radwindow as it appears in FullScreen.jpg image (Means that the radwindow control hides every thing behind, even the browser itself).

It is appreciated to help me with explaination and code.

Regards,
Bader
Georgi Tunev
Telerik team
 answered on 22 Sep 2010
4 answers
296 views

I have a RadListBox that I am trying to use to convert an old ASP page.  In my ASP page I was able to use a Select box with optgroup to create headers within the list box.  In this case, I have Headquarters as a non-selecteable bold header.  Then I have sites indented and beneath.  In trying to duplicate the functionality, I can't seem to make it work with RadListBox.  I can't find a way to group items in the listbox, so I am using Disabled for the headers and then trying to use CSS to format.  Overall, I'm almost there, but I can't get the CSS to change the color of the header text.  Since it's disabled, it's grey.  I have tried overriding the CSS and I can make the text larger, smaller,bold, italic, etc, but I can't get it to change color.  For the non-disabled items, I can change the color.  What's going on?  I'm using the Internet Explorer Developer Tools to view the applied CSS and it shows my new color as being applied to the disabled items, but it just won't display properly.

Here's the custom CSS I'm trying.

<style type="text/css">
.RadListBox_Default li.rlbDisabled
{   
   color:Black;
   font-weight: bold; 
   text-decoration:underline; 
   text-indent:0px;
   margin-left:0px;
}
.RadListBox_Default .rlbDisabled span.rlbText
{   
   color: Black;
   font-weight: bold; 
   text-decoration:underline; 
   font-size:10pt;
   text-transform:capitalize;
   font-family:Verdana;
   font-style:italic;
}
  
.RadListBox_Default li
{  
   margin-left:10pt;
}
.RadListBox_Default span.rlbText
{  
   font-family:Verdana;
   font-size:10pt;
}
  
  
</style>


This is the RadListBox.
<telerik:RadListBox
                runat="server"
                ID="rlbItemList"
                Height="400px" 
                Width="350px"
                AllowTransfer="true" AllowReorder="false"
                TransferToID="RadListBoxDestination"
                EnableEmbeddedBaseStylesheet="false"
                EnableEmbeddedSkins="false" 
                CssClass="ListBox"
            >
            </telerik:RadListBox>
  
        </td>
        <td>
            <telerik:RadListBox
                runat="server"
                ID="RadListBoxDestination"
                Height="400px"
                Width="350px" 
            />
Adam Gross
Top achievements
Rank 1
 answered on 22 Sep 2010
1 answer
117 views
I'm assigning the Css Class in the WebService, but it's not coming down clientside...

item.CssClass = "rrItem";
item.Html = html.ToString();

The only thing the Item has is the inline height style

Also is there a way to not have it re-call the service once it has its initial set of items?  I just want to populate it OnLoad then have it rotate through those items. **Edit** I dont want to do it on Page_Load serverside becasue it's calling a slow external service :)


**Edit #2 **

Since it's not returning the class I'm just wrapping the items in my own div with a classname (well it is coming down, I see it in the JSON, just not getting assigned to the nodes)
Fiko
Telerik team
 answered on 22 Sep 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?