Telerik Forums
UI for ASP.NET AJAX Forum
17 answers
737 views
Hi,

I have an RadGridView within an UpdatePanel and I want to export it to Excel. Than I discover a problem. I've already knew that Button which triggers the actual export should be registered as an postback control. I did it (according to the way found on telerik website). But it does not work. My GridView looks like this

    
   <telerik:RadGrid ID="gvSearchTelerik" runat="server" 
                         OnItemCreated="gvSearchTelerik_ItemCreated" 
                         EnableAjaxSkinRendering="false" 
                         AllowSorting="True" 
                         AllowPaging="True" 
                         PageSize="15" 
                         GridLines="None" 
                         Width="100%" 
                         AllowFilteringByColumn="True" 
                         DataSourceID="sqlSearchDevice" 
                         HeaderStyle-Wrap="false" 
                         HeaderStyle-Width="150px" 
                         ShowGroupPanel="True" 
                         ShowStatusBar="true"
                <MasterTableView CommandItemDisplay="Top"
                    <CommandItemTemplate> 
                        <asp:ImageButton ID="bXls" runat="server" 
                                         OnInit="bXls_Init" 
                                         OnPreRender="bXls_PreRender" 
                                         OnClick="bXls_Click" 
                                         style="margin:3px 2px 1px 2px" 
                                         SkinID="ExportToExcel"/>                                
                    </CommandItemTemplate> 
                    <Columns> 
                        <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" 
                                                 HeaderText="MojeIdecko"
                        </telerik:GridBoundColumn> 
                    </Columns> 
                </MasterTableView> 
                <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> 
                <ExportSettings IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true" > 
                    <Excel FileExtension="xls" Format="ExcelML" /> 
                </ExportSettings>                          
            <ClientSettings AllowDragToGroup="True" 
                            AllowColumnsReorder="true" 
                            ReorderColumnsOnClient="true"
                <Scrolling AllowScroll="True" 
                           UseStaticHeaders="True" 
                           SaveScrollPosition="true" 
                           FrozenColumnsCount="1" /> 
            </ClientSettings>                          
        </telerik:RadGrid>  


it is placed in the content page of a master page. Update panel is placed over the whole content in the master page. The code behind of the export function is

    protected void bXls_Click(object sender, ImageClickEventArgs e)  
    {  
        gvSearchTelerik.ExportSettings.ExportOnlyData = true;  
        gvSearchTelerik.ExportSettings.IgnorePaging = true;  
        gvSearchTelerik.ExportSettings.OpenInNewWindow = true;  
        gvSearchTelerik.MasterTableView.ExportToExcel();  
    }  


i registered the button as postback control in the ItemCreated event of the gridview

    protected void gvSearchTelerik_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
     if (e.Item is GridCommandItem) 
       { 
           ImageButton ibExportToExcel = (e.Item as GridCommandItem).FindControl("bXls"as ImageButton; 
           this.RegisterPostbackControl(this, ibExportToExcel); //this function just registers input control
// via ScriptManager placed on the MasterPage
       } 
    } 


however, each time i click the export button an asynchronous postback is made, not just fullpostback and GridView is not exported.
I tried other solution written on the telerik website, but non of them seem to work. What I've discovered was fact that export is made only for the first time. In other words, export is working, but when i made some postback on the page, export button does not cause full postback anymore.

please help.

thanks


Daniel
Telerik team
 answered on 31 May 2011
3 answers
157 views
Hello All,

I want to make a Gridview with a default grouping. For example i have 2 tables. The first one includes Countries and Country IDs. The second contains ID, ContactName, Email, CountryID.

I have 3 Country record in my Countries table and 5 Contact record in my Contacts table. 3 of my contacts belong to CountryID 1 and 2 of them to CountryID 2. There is no contacts for CountryID 3.

I want to group my grid by countries and show all the 3 country and contacts below.

The second condition is i want to be able to move this contacts between this groups. (Of course the records will be updated)

A sample view of my finish work is attached. I get all my countries by grouping in SQL Query. Bu the mistake is i get 1 record for the empty Country record. It souldnt.

My SQL Query is like:

SELECT Contacts.ID, Contacts.ContactName, Contacts.Email, Countries.ID AS CountryID, Countries.CountryName, COUNT(Contacts.ID) AS TotalContacts

FROM Contacts RIGHT OUTER JOIN Countries ON Contacts.CountryID = Countries.ID

GROUP BY Contacts.CountryID, Countries.ID, Countries.CountryName, Contacts.ContactName, Contacts.Email, Contacts.ID

<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlData"
    AutoGenerateColumns="False" AllowSorting="True" AllowMultiRowSelection="False"
    AllowPaging="True" PageSize="15" GridLines="None" OnRowDrop="RadGrid1_RowDrop">
    <PagerStyle Mode="NumericPages"></PagerStyle>
    <MasterTableView DataSourceID="SqlData" DataKeyNames="ID" GroupLoadMode="Server">
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField FieldAlias="Country" FieldName="Country"></telerik:GridGroupByField>
                    <telerik:GridGroupByField FieldName="TotalContact" Aggregate="Count"></telerik:GridGroupByField>
                </SelectFields>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="Country"></telerik:GridGroupByField>
                </GroupByFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
        <Columns>
            <telerik:GridDragDropColumn HeaderStyle-Width="18px" />
            <telerik:GridBoundColumn SortExpression="ID" HeaderText="ID" HeaderButtonType="TextButton" datafield="ID" UniqueName="ID" />
            <telerik:GridBoundColumn SortExpression="ContactName" HeaderText="Name" HeaderButtonType="TextButton" datafield="ContactName" UniqueName="ContactName" />
            <telerik:GridBoundColumn SortExpression="Country" HeaderText="Country" HeaderButtonType="TextButton" DataField="Country" UniqueName="Country" />
        </Columns>
    </MasterTableView>
    <ClientSettings AllowRowsDragDrop="true"
       <Selecting AllowRowSelect="True" EnableDragToSelectRows="false" /> 
    </ClientSettings>
</telerik:RadGrid>
Marin
Telerik team
 answered on 31 May 2011
1 answer
332 views
Hi All,
  I am trying to make the gridview row bold, The first row of my gridview is linkbuttons. when someone clicks on the linkbutton then I want to make the row bold, this works fine in my code, I want to show a pop up message to the user if the user clicks on another link button. the pop up message should say "You are leaving the link (Old Link Button ID) and you are going to (new link button ID) here. Are you Sure? if the user clicks "Yes" in the pop up window then I need to bold the new link button row that the user just clicked otherwise if the user clicks "NO" or cancel then I need to keep the old link button row bolded.

I tried lot of things and put lot of hours in it, but couldn't get forward with this.  Below is my code
This is inside the DataBound event of grid:
 foreach (GridDataItem item in RadGrid_IDPicker.Items)
                {
  
                    if (Convert.ToString(DataBinder.Eval(item.DataItem, "IID")) == lblID.Text)
                    {
                         
                        item.Style.Add(HtmlTextWriterStyle.FontWeight, "Bold");
                       
                    }
if (lblIDTemp.Text != lblID.Text)
{
  
   string radalertscript = "<script language='javascript'>function f(){confirm_select('" + lblIDtemp.ClientID + "'); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
  
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", radalertscript);
  
}
        
}

In above code lblIDTemp is the value of the old link button which I stored in a hidden variable and lblID is the new link button value which i stored in another hidden varaible.

Any help will be higly apprecaited. I am trying to solve this problem since morning and don't know how to solve it.

Maria Ilieva
Telerik team
 answered on 31 May 2011
2 answers
67 views
I created a Telerik AJAX project and added a web page with master page. I added RadScriptManager, RadAjaxManager and RadGrid and set the columns. The grid is set to allow sorting and filtering via the telerik options. If I get the data, the filtering and sorting returns a page with only a small area in it - not filled with any data and not showíng the empty grid text. What is going wrong? Can you please help me to get this up?

Here is my page definition:

 

 

<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">

 

 

 

</telerik:RadScriptManager>

 

 

 

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

 

 

 

<AjaxSettings>

 

 

 

<telerik:AjaxSetting AjaxControlID="OverviewGrid">

 

 

 

<UpdatedControls>

 

 

 

<telerik:AjaxUpdatedControl ControlID="OverviewGrid" />

 

 

 

</UpdatedControls>

 

 

 

</telerik:AjaxSetting>

 

 

 

</AjaxSettings>

 

 

 

</telerik:RadAjaxManager>

 

 

 

<telerik:RadGrid ID="OverviewGrid" runat="server" AllowFilteringByColumn="True"

 

 

 

 

AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"

 

 

 

 

CellSpacing="0" CssClass="grid" Skin="WebBlue" GridLines="None">

 

<

 

 

MasterTableView>

 

 

<

 

 

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:GridHyperLinkColumn DataNavigateUrlFields="ObjectId"

 

 

 

 

DataNavigateUrlFormatString="Request.aspx?ObjectId={0}"

 

 

 

 

DataTextField="Employee" FilterControlAltText="Filter Employee"

 

 

 

 

HeaderText="Employee" SortExpression="Employee" Target="_blank"

 

 

 

 

UniqueName="Employee">

 

 

 

</telerik:GridHyperLinkColumn>

 

 

 

<telerik:GridBoundColumn DataField="Division"

 

 

 

 

FilterControlAltText="Filter Division" HeaderText="Division"

 

 

 

 

SortExpression="Division" UniqueName="Division">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn DataField="CostCenter"

 

 

 

 

FilterControlAltText="Filter Cost Center" HeaderText="Cost Center"

 

 

 

 

SortExpression="CostCenter" UniqueName="CostCenter">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn DataField="RequestPeriod"

 

 

 

 

FilterControlAltText="Filter Request Period" HeaderText="Date"

 

 

 

 

SortExpression="RequestPeriod" UniqueName="RequestPeriod" DataFormatString="{0:d}">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridNumericColumn DataField="Hours" DecimalDigits="2"

 

 

 

 

FilterControlAltText="Filter Hours" HeaderText="Hours"

 

 

 

 

SortExpression="Hours" UniqueName="Hours" DataFormatString="{0:N}">

 

 

 

</telerik:GridNumericColumn>

 

 

 

<telerik:GridBoundColumn DataField="Reason"

 

 

 

 

FilterControlAltText="Filter Reason" HeaderText="Reason"

 

 

 

 

SortExpression="Reason" UniqueName="Reason">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridNumericColumn DataField="Overtime" DecimalDigits="2"

 

 

 

 

FilterControlAltText="Filter Overtime" HeaderText="Current Overtime"

 

 

 

 

SortExpression="Overtime" UniqueName="Overtime" ReadOnly="true" DataFormatString="{0:N}">

 

 

 

</telerik:GridNumericColumn>

 

 

 

<telerik:GridCheckBoxColumn DataField="ApprovalSuperior"

 

 

 

 

FilterControlAltText="Filter Superior Approval" HeaderText="Superior"

 

 

 

 

SortExpression="ApprovalSuperior" UniqueName="ApprovalSuperior" ReadOnly="true">

 

 

 

</telerik:GridCheckBoxColumn>

 

 

 

<telerik:GridCheckBoxColumn DataField="ApprovalCctResponsible"

 

 

 

 

FilterControlAltText="Filter Cost Center Approval" HeaderText="Cost Center"

 

 

 

 

SortExpression="ApprovalCctResponsible" UniqueName="ApprovalCCT" ReadOnly="true">

 

 

 

</telerik:GridCheckBoxColumn>

 

 

 

<telerik:GridCheckBoxColumn DataField="ApprovalBuResponsible"

 

 

 

 

FilterControlAltText="Filter BU Responsible Approval" HeaderText="HR BU"

 

 

 

 

SortExpression="ApprovalBuResponsible" UniqueName="ApprovalBU" ReadOnly="true">

 

 

 

</telerik:GridCheckBoxColumn>

 

 

 

<telerik:GridCheckBoxColumn DataField="ApprovalHeadHr"

 

 

 

 

FilterControlAltText="Filter Head HR Approval" HeaderText="Head HR"

 

 

 

 

SortExpression="ApprovalHeadHr" UniqueName="ApprovalHR" ReadOnly="true">

 

 

 

</telerik:GridCheckBoxColumn>

 

 

 

<telerik:GridCheckBoxColumn DataField="ApprovalWorksCouncil"

 

 

 

 

FilterControlAltText="Filter Works Council Approval" HeaderText="Works Council"

 

 

 

 

SortExpression="ApprovalWorksCouncil" UniqueName="ApprovalWC" ReadOnly="true">

 

 

 

</telerik:GridCheckBoxColumn>

 

 

 

<telerik:GridCheckBoxColumn DataField="ApprovalEmployee"

 

 

 

 

FilterControlAltText="Filter Employee Approval" HeaderText="Employee"

 

 

 

 

SortExpression="ApprovalEmployee" UniqueName="ApprovalEmployee" ReadOnly="true">

 

 

 

</telerik:GridCheckBoxColumn>

 

 

 

</Columns>

 

<

 

 

EditFormSettings>

 

 

<

 

 

EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>

 

 

</

 

 

EditFormSettings>

 

 

</

 

 

MasterTableView>

 

<

 

 

FilterMenu EnableImageSprites="False"></FilterMenu>

 

<

 

 

HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>

 

 

 

</telerik:RadGrid>

 


Do I have to program something or will it work automatically?
Birgit
Top achievements
Rank 1
 answered on 31 May 2011
2 answers
149 views
I want to create a confirmation message box using java script. Once they hit ok or cancel i should go to a function written in .cs.
Could anyone give a solution for this ..?
$uren
Top achievements
Rank 1
 answered on 31 May 2011
2 answers
135 views
Hi,
I was looking at this project and could not understand a part of the javascript.
There is an asmx file in the project called Authentication. It has a method IsLoggedIn:

[ScriptService]
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Authentication : WebService
{
   [WebMethod]
    public bool IsLoggedIn()
    {
        return Context.User.Identity.IsAuthenticated;
    }
}

In the file ToolTip.aspx, that method is called as such:

<telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
    <script type="text/javascript">
 
    function OnClientBeforeShow(sender, eventArgs)
    {
        Authentication.IsLoggedIn(successfulAuthCallback, failedAuthCallback, eventArgs);        
    }         
        
    function successfulAuthCallback(isLoggedInResult,eventArgs) {
 
        if (isLoggedInResult != true)           
        
            // reload the entire page so the Forms Auth will see that the cookie has expired and redirect to login
            window.location.reload(true);
        }        
    }
                  
    function failedAuthCallback(result, eventArgs)        
    {           
        alert("Auth Callback failed: Reason -- " + result);        
    }
    </script>
</telerik:RadCodeBlock>

My confusion stems from the fact that:
  1. IsLoggedIn has no formal parameters. However, it is being passed 3 parameters.
  2. I cannot see wheresuccessfulAuthCallback is being passed 2 parameters. It has two parameters. But where are they being passed to it.

Cheers
David
Top achievements
Rank 1
 answered on 31 May 2011
2 answers
77 views

Hi,
I have a really simple scenario here where i have a button in a panel of which is then ajaxified with the radajaxmanager as below. The problem i see here is that every second postback a standard (non-asyncronous) postback is occurring as shown by the IsAjaxRequest property being displayed in the alert.  Is there something really obvious i am missing here ?

Thanks

Ady


public partial class WebForm2 : System.Web.UI.Page 
    { 
     
        Panel panel; 
        Button button; 
 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            AddControls();   
        } 
 
 
        void AddControls() 
        { 
            //Create controls 
            panel = new Panel(); 
            button = new Button { Text = "Update" }; 
            
 
            //Add event handler 
            button.Click += new EventHandler(button_Click); 
 
            //Add controls 
            Form.Controls.Add(panel); 
           
            panel.Controls.Add(button); 
 
            //Register with manager 
           
            RadAjaxManager1.AjaxSettings.AddAjaxSetting(panel, button, null); 
        } 
 
        void button_Click(object sender, EventArgs e) 
        { 
            RadAjaxManager1.Alert(RadAjaxManager1.IsAjaxRequest.ToString()); 
        } 
 
 
    } 

Jeremy
Top achievements
Rank 1
 answered on 31 May 2011
2 answers
137 views
I'm not sure why the search engines are turning up cached forum threads with issues about RadAsyncUpload and the Mac but that they seem to be either deleted or moved here on the forums, but I am also experiencing issues with the RadAsyncUpload working for the Mac.

Is there any status on suggestions or what's going on here?  I've read on the forums (cached google) that we should disable flash to get it to work, but can Telerik provide some feedback on this?

Thanks!
Genady Sergeev
Telerik team
 answered on 31 May 2011
2 answers
82 views
Hi,
Is it possible to disply all day time in dayview?(Is it supported by the scheduler control)
for example
instead of 1 PM display 13:00
I've set the property ShowFullTime="True" but this is not the solution.
Alon
Top achievements
Rank 1
 answered on 31 May 2011
8 answers
136 views
<%@ Page Language="VB"AutoEventWireup="false"CodeFile="Default.aspx.vb"Inherits="_Default"%> 
    
<!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> 
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1"runat="server"/> 
</head> 
<body> 
    <form id="form1"runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1"runat="server"
        <Scripts> 
            <%--Needed for JavaScript IntelliSense in VS2010--%> 
            <%--ForVS2008 replace RadScriptManager with ScriptManager--%> 
            <asp:ScriptReference Assembly="Telerik.Web.UI"Name="Telerik.Web.UI.Common.Core.js"/> 
            <asp:ScriptReference Assembly="Telerik.Web.UI"Name="Telerik.Web.UI.Common.jQuery.js"/> 
            <asp:ScriptReference Assembly="Telerik.Web.UI"Name="Telerik.Web.UI.Common.jQueryInclude.js"/> 
        </Scripts> 
    </telerik:RadScriptManager> 
    
    <script type="text/javascript"
        //Put your JavaScript code here. 
            function OnClientFormCreated(sender, eventArgs)  
            
                $telerik.$(".rsAdvWeekly_WeekDays li:first-child").hide(); 
                $telerik.$(".rsAdvWeekly_WeekDays li:last-child").hide();                                                  
    
            }   
                
            function OnClientRecurrenceActionDialogShowing(sender, eventArgs)  
            
                 eventArgs.set_cancel(true); 
                    //Edit this instance only: 
                    //eventArgs.set_editSeries(false); 
                        
                    //Edit the entire series: 
                 eventArgs.set_editSeries(true); 
            }      
    </script> 
    
    <telerik:RadAjaxManager ID="RadAjaxManager1"runat="server">         
    </telerik:RadAjaxManager> 
       
    <div> 
        <telerik:RadScheduler ID="RadScheduler1"runat="server"Skin="Office2007"DataEndField="EndDate"
            DataKeyField="ID"DataRecurrenceField="RecurrenceRule"DataRecurrenceParentKeyField="RecurrenceParentID"
            DataSourceID="ldsActivitySchedules"DataStartField="StartDate"DataSubjectField="Subject"
            OnClientFormCreated="OnClientFormCreated()"OnClientRecurrenceActionDialogShowing="OnClientRecurrenceActionDialogShowing"
            AllowDelete="False" 
            EnableCustomAttributeEditing="True"FirstDayOfWeek="Monday" 
            LastDayOfWeek="Friday"MinutesPerRow="15"ShowAllDayRow="False"Width="700px"Height="650px"
            <TimelineView UserSelectable="False"/> 
            <AdvancedForm EnableCustomAttributeEditing="True"Modal="True"/> 
            <ResourceTypes> 
                <telerik:ResourceType DataSourceID="ldsActivities"ForeignKeyField="ActivityID" 
                    KeyField="ID"Name="Activities"TextField="Description"/> 
            </ResourceTypes> 
        </telerik:RadScheduler> 
        <asp:LinqDataSource ID="ldsActivities"runat="server" 
            ContextTypeName="DataClassesDataContext"EnableInsert="True" 
            EnableUpdate="True"OrderBy="Description"TableName="ACTIVITies"
        </asp:LinqDataSource> 
        <asp:LinqDataSource ID="ldsActivitySchedules"runat="server"ContextTypeName="DataClassesDataContext"
            EnableInsert="True"EnableUpdate="True"OrderBy="StartDate"TableName="ACTIVITYSCHEDULEs"
        </asp:LinqDataSource> 
    </div> 
    </form> 
</body> 
</html>
Hi Veronica,

Sorry for the delay.

Per your request, I created a new support thread and pasted the full code of my default.aspx page here again. 
To answer your question, I used Internet Explorer version 7.0.5730.13 to run my application.
Also, I used RadScheduler version 2010.3.1109.35, and this caused this issue when I tried to hide Saturday and Sunday checkboxes.

Hope you can help me to solve this problem.

Thanks so much for your hard work.

Tiffany Phan

Veronica
Telerik team
 answered on 31 May 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
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?