Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
541 views
I have created my RadGrid and have exporting to Excel working well when the user clicks on an export button in their browser.

I have also used the code below to make it so that the Excel file can be saved programatically without bringing up the file save dialog.  This code is also working well.

Now, what I need to do is automate and schedule this process:   the creation of the grid, the firing off the export to Excel function, and saving that exported Excel file to a directory on the web server.  In order to accomplish that, I created a windows application that would sit on the same web server and would call the web page that contains the grid.   That works fine.

The problem that I have is that I don't know how to fire the GridExporting event without using some client side interaction or client-side javascript.   I am using an HttpWebRequest in my windows application to make the web request, but HttpWebRequest doesn't support javascript, so it can't trigger the GridExporting event.

Is there anyway to call the GridExporting event from the server-side and not the client-side?   If so, during what event should I make that call from and what does that call look like?

I know that as an alternative, I could totally skip using RadGrid, and for these automated exporting calls, simply take my raw data and create an excel sheet programatically using NPOI or some other tool and save it.   The issue is that I will still be using RadGrid on the web, and I have built the web application so that the data in the grid can be customized significantly by my users (through sorting, grouping, hiding columns, etc), and I really want the programatically created Excel file to provide the same data, in as close to the same format, as if the user used the RadGrid's export to Excel function on the website.  

It seems that I am very close to making that happen, if I can just figure out how to trigger the export function on the server-side.

Thanks in advance for your help!


This is the code that I am using to save the Excel file programatically without bringing up the file save dialog.  This code is working great.
Protected Sub RadGrid1_GridExporting(sender As Object, e As Telerik.Web.UI.GridExportingArgs) Handles myGrid.GridExporting
        'This handler saves the file DIRECTLY to the server directory without showing the save as dialog
             
            path = Server.MapPath("~/MyFile.xls")
 
            Dim fs As FileStream
            fs = File.Create(path)
 
            Dim info As Byte()
            info = System.Text.Encoding.Default.GetBytes(e.ExportOutput)
            fs.Write(info, 0, info.Length)
            fs.Close()
 
            Response.Redirect(Request.Url.ToString(), False)
 
    End Sub
Daniel
Telerik team
 answered on 31 Jan 2013
2 answers
157 views
Hi,

How can I disable the title on the content area?
I have a title said: Rich text editor with ID...

I'm using the div mode.

As you can see in this demo, there is the title also:
http://demos.telerik.com/aspnet-ajax/editor/examples/contentareamodediv/defaultcs.aspx
Attila
Top achievements
Rank 1
 answered on 31 Jan 2013
3 answers
148 views
Is there a way to get FormDecorator to style custom controls i have on my page? They are just modified DropDownList controls but the FormDecorator doesn't pick them up.
Danail Vasilev
Telerik team
 answered on 31 Jan 2013
3 answers
140 views
Hello,

I have a search function on every page. The way this works is that a button is pressed the Master page catches the button press and then redirects to a "suche.aspx" page.

On updating the Telerik dll this has stopped working in IE8. IE8 tries to download a file.

What I think causes the problem is at some point an extra "Response header" is added, "Content-encoding: gzip", so that there are now two, which confuses the browser (but not IE9 or Firefox -- FF renders the header as "Content-encoding: gzip, gzip" but accepts it).

The answer seems to be to use Response.ClearHeaders() before the redirect (or turning off postback compression, which worked when this problem was confined to a couple of pages and I could use the "excludeHandler" for those) .

I am hesitant, however, as a previous DLL required the removing of Response.ClearHeaders() for IE8 to work and I thought it best to get clarification as to the best practice here.

Thank you

Paul Herzberg
Martin
Telerik team
 answered on 31 Jan 2013
1 answer
102 views

I output RadGrid to Excel <Excel Format="Html"></Excel>

Here are my issues; (I have attached a picture to help illustrate my questions)

 

  1. Is there a way to know what row the Grid is currently writing to in Excel? Something like "Excel.CurrentRowNumber"?

Reason: I'm writing formulas to various cells during RadGrid1_ExcelExportCellFormatting but the first row of data it encounters gets written to Excel row 4 (because of the Grid Header). I tried using item.ItemIndex but that starts off at 0 (or 1 maybe, i don't recall). So my formulas are all messed up since I don't know what the current row in Excel is. I need to write out formulas like C4+D4 but I end up with C1+D1.
The problem gets worse as  GroupByExpressions are encountered. Each time my data is grouped another 2 rows get written to Excel and now my current row is off by even more.

2. Is there a way to interact with the output to Excel when GroupByExpressions are encountered? I'd like to adjust the cells during that time such as inserting formulas to sum up all the rows in a section for each column. Same question regarding the GridFooterItem..? I'd like to put "grand total formulas" in those various columns.

3. I can't get rid of column A. There is a blank column that gets written out (see my picture). It seems to be known as "column" so I tried hiding it such as:

RadGrid1.MasterTableView.GetColumn("column").Display = false;

but no luck. This is only a minor annoyance, I could live with this as the formula questions above are the more important showstoppers.

Thank you!!

Daniel
Telerik team
 answered on 31 Jan 2013
1 answer
86 views
I have a menu that has background images.  The menu is the appropriate width (lining up with other items within the div container) when zoom is set to 100% in IE, Chrome and Firefox.  However, when I zoom in the width varies in relation to the other items on the page.  Sometimes the overall width is narrower than it should be.  Other times it is wider than the container, which causes it to wrap.

Any insight into what the cause might be would be greatly appreciated!

Thank you,
--Larry--
Ivan Zhekov
Telerik team
 answered on 31 Jan 2013
1 answer
184 views
I have a RadTabStrip + RadMultiPageView + RadPageView + RadWindow on mainpage.aspx

RadPageView  I am utilizing contenturl='contentpage.aspx'

I am wanting to do the following call on contentpage.aspx

var w = radopen('dialogpage.aspx', null);

w.maximize();

w.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close);


But this only sets it to full screen within the bounds of RadPageView.

I cant do
var w = parent.radopen('dialogpage.aspx', null);

w.maximize();

w.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close);


as I loose the ability to send requests back to the opening page utilizing:
function GetRadWindow()
{
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz as well)
return oWindow;
};
function CloseAndRebind()
{
GetRadWindow().Close();
GetRadWindow().BrowserWindow.UpdateFromPopup('information being passed back');
};

UpdateFromPopup would be called on mainpage.aspx instead of contentpage.aspx
any ideas on how to get the radwindow to maximize??
Marin Bratanov
Telerik team
 answered on 31 Jan 2013
1 answer
98 views
Hello,

While working with the TreeList Drag and Drop example, I've noticed that there doesn't appear to be a way to drag child nodes to the top-most level. Given that it is possible to drag root nodes beneath their peers to create child nodes, and since this functionality can be seen in the TreeView Drag and Drop example, I would expect that the control also supports the aforementioned scenario.

So, is there a property or setting that I must set to enable this behavior on the TreeList, or if the implementation is more complex, may I request an example showing how to achieve this?

UPDATE: I've managed to implement this functionality using a custom "ItemDrop" event handler. I'm still interested in identifying a simpler solution though.
Andrey
Telerik team
 answered on 31 Jan 2013
3 answers
74 views
Why have none of the latest webinars been posted online?
Most of us are not able to attend the webinars live due to time differences.

Are those of us who do not live in the US now no longer allowed to watch them?
Rumen
Telerik team
 answered on 31 Jan 2013
1 answer
132 views
Hi ,

I am strange issue in particular page.
I am using client side binding using following tag
        <DataBinding Location="~/ReportManagement/ReportDesigner.aspx" SelectMethod="wmBindSecurity" />
After page load 10 records display properly, but in pagination bar page number is missing ,and also it is written 0 items in 0 pages.
and page size changing works perfectly.


On change of next or prev request is not going to server side.

Please help me .
I am using following code.

ASPX
<telerik:RadGrid ID="rgSecurity" runat="server" AllowPaging="true" AllowMultiRowSelection="True"
                           GridLines="None" AllowSorting="true" Width="99%">
                           <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />
                           <ItemStyle Wrap="false" />
                           <HeaderStyle Wrap="false" />
                           <ClientSettings EnableRowHoverStyle="true" AllowColumnsReorder="true" AllowColumnHide="true"
                               Resizing-AllowColumnResize="true" Resizing-EnableRealTimeResize="true" ReorderColumnsOnClient="true">
                               <Resizing ResizeGridOnColumnResize="true" ClipCellContentOnResize="false" />
                               <DataBinding Location="~/ReportManagement/ReportDesigner.aspx" SelectMethod="wmBindSecurity" />
                               <Selecting AllowRowSelect="true" />
                               <ClientEvents OnRowSelected="RowSelected" OnRowDeselected="RowSelected" OnDataBindingFailed="rgSecurity_OnDataBindingFailed">
                               </ClientEvents>
                           </ClientSettings>
                           <MasterTableView AutoGenerateColumns="false" AllowNaturalSort="false" ClientDataKeyNames="Id"
                               CommandItemDisplay="Top">
                               <CommandItemTemplate>
                                   <telerik:RadToolBar ID="rtbSecurity" runat="server" Height="26px" Width="100%" ClientIDMode="Static"
                                       OnClientButtonClicking="rtbSecurity_onToolBarClientButtonClicking">
                                       <Items>
                                           <telerik:RadToolBarButton Text="Add" ImageUrl="~/Images/NewEnable2.png" runat="server"
                                               ClientIDMode="Static" Value="Add" CommandName="Add" CssClass="RadToolBar">
                                           </telerik:RadToolBarButton>
                                           <telerik:RadToolBarButton Text="Remove" ImageUrl="~/Images/imgDelBtnEnable.png" runat="server"
                                               ClientIDMode="Static" Value="Delete" CommandName="Delete" CssClass="RadToolBar"
                                               Enabled="false">
                                           </telerik:RadToolBarButton>
                                       </Items>
                                   </telerik:RadToolBar>
                               </CommandItemTemplate>
                               <Columns>
                                   <telerik:GridClientSelectColumn UniqueName="column" HeaderStyle-Width="35px" ItemStyle-Width="35px"
                                       Resizable="false">
                                   </telerik:GridClientSelectColumn>
                                   <telerik:GridTemplateColumn UniqueName="Name" HeaderText="Name" SortExpression="Name"
                                       ShowSortIcon="true" ItemStyle-Wrap="false">
                                       <ClientItemTemplate>
                                           <label id="aName_#=Id#" border="0"  #=Type == 0 ? "style='background: url(../Images/usersetting.png) top left no-repeat !important;padding-left:18px'" :  "style='background: url(../Images/user-groups.png) top left no-repeat !important;padding-left:18px'"#>#=Name#</label>
                                       </ClientItemTemplate>
                                       <ItemStyle Wrap="false" />
                                       <HeaderStyle Wrap="false" />
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="AllowRead" HeaderText="Read" SortExpression="AllowRead"
                                       ShowSortIcon="true" HeaderStyle-Width="10%" ItemStyle-Width="10%">
                                       <ClientItemTemplate>
                                           <input type="checkbox" id="chk_read_#=Id#" #=AllowRead == true ? "checked" : "" # #=AllowWrite == true ? "disabled" : "" # onclick="javascript:OnChangeSecurity('#=Id#','#=Type#')"/>
                                       </ClientItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="AllowWrite" HeaderText="Write" SortExpression="AllowWrite"
                                       ShowSortIcon="true" HeaderStyle-Width="15%" ItemStyle-Width="15%">
                                       <ClientItemTemplate>
                                             <input type="checkbox" id="chk_write_#=Id#" #=AllowWrite == true ? "checked" : "" # onclick="javascript:OnChangeSecurity('#=Id#','#=Type#')"/>
                                       </ClientItemTemplate>
                                   </telerik:GridTemplateColumn>
                               </Columns>
                           </MasterTableView>
                       </telerik:RadGrid>


JS

function RowSelected(rowObject, args) {

            if (args != null)
                gridEventArg = args;

            var length = $find(rgSecurity_id).get_selectedItems().length;
            var radGrid = $get(rgSecurity_id);
            var radToolBar = $telerik.findControl(radGrid, "rtbSecurity");
            var addButton = radToolBar.get_items().getItem(0);
            var removeButton = radToolBar.get_items().getItem(1);
            switch (parseInt(length)) {
                case 0:
                    addButton.set_enabled(true);
                    removeButton.set_enabled(false);
                    break;
                case 1:
                    addButton.set_enabled(false);
                    removeButton.set_enabled(true);
                    break;
                default:
                    addButton.set_enabled(false);
                    removeButton.set_enabled(true);
                    break;
            }
        }
[WebMethod]
       public static Dictionary<string, object> wmBindSecurity(int startRowIndex, int maximumRows, List<GridSortExpression> sortExpression, List<GridFilterExpression> filterExpression)
       {
           if (HttpContext.Current.Session["UserName"] == null)
               throw new Exception("SESSION_TIMEOUT");
 
           Dictionary<string, object> data = new Dictionary<string, object>();
 
           if (HttpContext.Current.Session["AnalystFile"] == null)
               throw new Exception("SESSION_TIMEOUT");
 
           List<SQCUser> allUsers = SQCUserList.GetUserList();
 
           List<SQCUserGroup> allGroups = SQCUserGroupList.GetGroupList();
 
           List<SQCUserGroupResourceMapping> lstUserGroupResourceMapping = ((SQWAnalystFile)HttpContext.Current.Session["AnalystFile"]).UserGroupReportMapping;
 
           List<SQCUserResourceMapping> lstUserResourceMapping = ((SQWAnalystFile)HttpContext.Current.Session["AnalystFile"]).UserReportMapping;
 
           List<SQCUser> oUsers = SQCUserList.GetUserList();
 
           var oData = lstUserGroupResourceMapping.Select(o => new
           {
               Id = o.GroupId,
               Name = allGroups.Find(g => g.GroupId == o.GroupId).GroupName,
               Type = "User Group",
               AllowRead = o.AllowRead,
               AllowWrite = o.AllowWrite
           }).ToList();
 
           oData.AddRange(lstUserResourceMapping.Select(p => new
           {
               Id = p.UserId,
               Name = SQCUserList.GetUserByUserID(p.UserId).UserName,
               Type = "User",
               AllowRead = p.AllowRead,
               AllowWrite = p.AllowWrite
           }).ToList());
 
           if (oData.Count > 0)
                data.Add("Data", oData.Skip(startRowIndex).Take(maximumRows));              
           else
               data.Add("Data", new List<SQCUserGroupResourceMapping>());
           data.Add("Count", 0);
           return data;
 
       }

Thanks & Regards ,
Somnath 
Antonio Stoilkov
Telerik team
 answered on 31 Jan 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?