Telerik Forums
UI for ASP.NET AJAX Forum
7 answers
1.1K+ views
I am doing a custom export to excel where I load the grid, say 10 items on the first page, 3 pages long. The user then filters the grid using the built in filter column headers. That limits the grid to 14 items in 2 pages. The user clicks my export button where the following gets executed:


        /// <summary> 
        /// Exports data in grid to excel 
        /// </summary> 
        public void Export() 
        { 
            //rgdProjectWorksheets.ExportSettings.ExportOnlyData = true; 
            //rgdProjectWorksheets.ExportSettings.IgnorePaging = true; 
            //rgdProjectWorksheets.MasterTableView.ExportToExcel(); 
 
            PWDetailAccess pwa = new PWDetailAccess(); 
            DataTable dt = pwa.GetFlatExportData(Convert.ToInt32(Session[ApplicationConstants.SessionVariables.OrganizationID].ToString())); 
 
            List<int> idlist = GetVisibleIDList(); 
 
            HttpContext context = HttpContext.Current; 
            context.Response.Clear(); 
            foreach (DataColumn column in dt.Columns) 
            { 
                context.Response.Write(column.ColumnName + ","); 
            } 
            context.Response.Write(Environment.NewLine); 
            foreach (DataRow row in dt.Rows) 
            { 
                if (!idlist.Contains(Convert.ToInt32(row[PWDetailsSchema.ID].ToString()))) 
                    continue
                for (int i = 0; i < dt.Columns.Count; i++) 
                { 
                    context.Response.Write(row[i].ToString().Replace(","string.Empty) + ","); 
                } 
                context.Response.Write(Environment.NewLine); 
            } 
 
            context.Response.ContentType = "text/csv"
            context.Response.AppendHeader("Content-Disposition""attachment; filename=SA_FlatExport.csv"); 
            context.Response.End(); 
        } 
 
        private List<int> GetVisibleIDList() 
        { 
            List<int> idlist = new List<int>(); 
            for (int i = 0; i < rgdProjectWorksheets.MasterTableView.Items.Count; i++) 
            { 
                if (rgdProjectWorksheets.Items[i].Visible == true
                    idlist.Add(Convert.ToInt32(rgdProjectWorksheets.Items[i][PWDetailsSchema.ID].Text)); 
            } 
            return idlist; 
        } 

I compare my full custom datatable with the items in the grid to decide which items in my datatable I will include in the export. This works great on a grid with no paging. The problem arises when I have more than one page. It appears that the count in
rgdProjectWorksheets.MasterTableView.Items only holds the items on the current page. How do I iterate through all the items in all pages?


I've tried running the GetVisibleIDList method in the PreRender event (as this post suggests), but that does not seem to be working.
Any help would be much appreciated.
Thanks
Kris
Konstantin Dikov
Telerik team
 answered on 17 Dec 2014
1 answer
94 views
Hi,
I am using Telerik version 2012.3.1322.40.

I have spell check button in .aspx form as

<telerik:RadSpell ID="rdlSpellChk" Skin="Office2007" runat="server" ControlToCheck="txtSourceLang" TabIndex="3" />

When I click spell check button, popup window opens. But the buttons ignore, ignore all etc is hidden and i'm not able to resize the window as well.
Attached the screenshot for the same.

If i change browser zoom level as 75% or 150%, it looks fine. Is there any way to fix this problem
Thanks.
Haribala
Marin Bratanov
Telerik team
 answered on 17 Dec 2014
3 answers
140 views
Trying to add a click event on the peek template of a radtemplate tile as well as a click event to the tile itself.  If they click the tile I want it to go to the application that its is attacded to, this works and no problems.  We are trying to put a favorites linkbutton in a peek template so that they users can add the tile to there favorites which when they click it I just want the link button to have a commandname and commandargurment that save the id of the tile into a database of favorites for that user.  Can this be accomplished ???
<div>
       <telerik:RadTileList runat="server" ID="RadTileList1"></telerik:RadTileList>
   </div>
 
protected void Page_Load(object sender, EventArgs e)
       {
           if (!IsPostBack)
           {
               PopulateTileList(0);
               PopulateRadMenu();
                
           }
       }
       
       protected void PopulateTileList(int tileId)
       {
           string sqlWhere = string.Empty;
           if (tileId == 0)
           {
               sqlWhere = string.Empty;
           }
           else
           {
               sqlWhere = " where intDirectoriteId = " + tileId;
           }
 
 
           sql = "select intAppId, strAppName, strTooltip, strUrl, strNotes, s.strColor from tblApplications a INNER JOIN tblStatus s on s.intStatusID = a.intStatusID " + sqlWhere;
 
           mydatatable = new DataTable();
           mydatatable = c.GetReader(sql);
 
           TileGroup tg = new TileGroup();
           RadTileList1.Groups.Add(tg);
            
           foreach (DataRow row in mydatatable.Rows)
           {
               RadContentTemplateTile tile = new RadContentTemplateTile();
               tg.Tiles.Add(tile);
               LinkButton linkfav = new LinkButton();
               linkfav.Attributes.Add("runat", "server");
               linkfav.Click += new EventHandler(linkfav_Click);
               linkfav.Text = "favorites";
               linkfav.Attributes.Add("CommandName", "AddFavorites");
               linkfav.Attributes.Add("CommandArgument", row[0].ToString());
 
               tile.ID = row[0].ToString();
               tile.Name = row[1].ToString();
               tile.ContentContainer.GroupingText = row[1].ToString();
               tile.ToolTip = row[2].ToString();
              // tile.NavigateUrl = row[3].ToString();
               tile.BackColor = System.Drawing.ColorTranslator.FromHtml(row[5].ToString());
               //Peektemplate
               tile.PeekTemplateSettings.Animation = PeekTemplateAnimation.Slide;
               tile.PeekTemplateSettings.HidePeekTemplateOnMouseOut = true;
               tile.PeekTemplateSettings.ShowPeekTemplateOnMouseOver = true;
               tile.PeekContentContainer.Controls.Add(new LiteralControl(row[4].ToString()));
               tile.PeekContentContainer.Controls.Add(linkfav);
               tile.PeekTemplateSettings.CloseDelay = 0;
               tile.PeekTemplateSettings.ShowInterval = 0;
 
           }
            
       }
 
       private void PopulateRadMenu()
       {
           sql = "select intDirectoriteID, strDirectorite from tblDirectorite where bitActive = 1";
 
           rdmenu.DataTextField = "strDirectorite";
           rdmenu.DataValueField = "intDirectoriteID";
           rdmenu.CssClass = "Menuitems";
           rdmenu.DataSource = c.GetReader(sql);
           rdmenu.DataBind();
       }
 
       protected void rdmenu_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
       {
           switch (e.Item.Value)
           {
               case "1":
                   PopulateTileList(1);
                   break;
               case "2":
                   PopulateTileList(2);
                   break;
               case "3":
                   PopulateTileList(3);
                   break;
               case "4":
                   PopulateTileList(4);
                   break;
               case "5":
                   PopulateTileList(5);
                   break;
               case "6":
                   PopulateTileList(6);
                   break;
               case "7":
                   PopulateTileList(7);
                   break;
           }
       }
 
       protected void linkfav_Click(object sender, EventArgs e)
       {
               Response.Write("Try this LinkButton!");
          
       }
   }
Marin Bratanov
Telerik team
 answered on 17 Dec 2014
1 answer
107 views
Trying to get the DataKeyValue/Primary key of selected row of RadGrid upon clicking Radiobutton

I tried below code but everytime its returning null in "string key"

<telerik:RadGrid ID="RadGrid1" EnableViewState="false" runat="server" AllowPaging="true" AllowSorting="False" AllowFilteringByColumn="true" GridLines="None" OnInit="RadGrid1_Init" OnDeleteCommand="RadGrid1_DeleteCommand">
        <ItemStyle Wrap="false"></ItemStyle>
         <MasterTableView AllowMultiColumnSorting="true" TableLayout="Fixed" DataKeyNames="Id" ClientDataKeyNames="Id">
                 <Columns>
                        <telerik:GridNumericColumn DataField="Id" HeaderText="Id" HeaderStyle-Width="100px" AllowFiltering="False" FilterControlWidth="50px">
                         <telerik:GridTemplateColumn UniqueName="" HeaderText="Select">
                                <ItemTemplate>
                                        <asp:RadioButton ID="rbdSelect" runat="server" AutoPostBack="true" OnCheckedChanged="rbdSelect_CheckedChanged"></asp:RadioButton>
                                 </ItemTemplate>
                          </telerik:GridTemplateColumn>
                  </Columns>
            </MasterTableView>
protected void rbdSelect_CheckedChanged(object sender, EventArgs e)
        {          
            foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
            {
                RadioButton rbd = (RadioButton)item.FindControl("rbdSelect");
                if (rbd.Checked == true)
                {
                    string key = item.GetDataKeyValue("Id").ToString();
                    Response.Redirect("~/Default.aspx");
                }
            }
        }
Please reply what is wrong in my code
Eyup
Telerik team
 answered on 17 Dec 2014
2 answers
187 views
I have two listboxes, lbSelectPhones and lbPhonesDest.  Everything is working great for selecting the desired phones in lbSelectPhones and transferring to lbPhonesDest.  I then store the selections in a SQL table comma separated like CR,CE,CN.

What I need to do now is use that comma separated value CR,CE,CN to auto transfer those selections from lbSelectPhones to lbPhonesDest when the user selects an item from a drop down list.  I've searched with no luck on finding a way to do this.  Please help.

I've tried using lbSelectPhones.Transfer("CR",lbSelectPhones,lbPhonesDest), but it doesn't work since the first argument can't be a string value.
Plamen
Telerik team
 answered on 17 Dec 2014
2 answers
121 views
So, I have the following scenario: an ASPNET webpage is launching a modal popup using RadWindow and its NavigateUrl property. The NavigateUrl points to an external, independent, ASPNET MVC application (within the same domain though). All works smoothly expect for one thing: the external MVC app has its own close logic and button to trigger that. Thing is that it obviously ain't working; the modal window hangs in there.
Being an external MVC app and all that, I guess it is out of the question to get hold of a reference to the RadWindow belonging to the host application...

Is there any solution to this scenario, at all? Thanks.
Cristian
Top achievements
Rank 1
 answered on 17 Dec 2014
1 answer
59 views
Dear Telerik Admin, 

Can you share a code for adding New RadTreeView into RadPanelBar programmatically on code behind in ASP.Net Vb.Net.

Thanks.
Nencho
Telerik team
 answered on 16 Dec 2014
4 answers
165 views
I'm having a problem accessing controls in the RadAjaxManager.  The controls are within an item template in the RadPanelBar.  Is there a way to access these?

  Here's a code snippet.  In this example, lbxOrg will be using Ajax to update the lbxContract.  However, I get an error with this - seems like lbxOrg cannot be found by the RadAjaxManager. 

 

 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
 
<AjaxSettings> 
 
<telerik:AjaxSetting AjaxControlID="lbxOrg">  
 
 <UpdatedControls> 
 
<telerik:AjaxUpdatedControl ControlID="lbxContract"/>  
 
</UpdatedControls> 
 
</telerik:AjaxSetting> 
 
</AjaxSettings> 
 
</telerik:RadAjaxManager> 
 
 
 
<telerik:RadPanelBar ID="RadPanelBar1" Width="100%" runat="server" ExpandMode="MultipleExpandedItems" 
 
Skin="Gray">  
 
<Items> 
 
<telerik:RadPanelItem Value="Items" Text="Filters">  
 
<Items> 
 
 
<telerik:RadPanelItem Value="FiltersItem">  
 
<ItemTemplate> 
 
 
 
<asp:ListBox ID="lbxOrg" runat="server" Rows="10" AutoPostBack="True"   
 
SelectionMode="Multiple" OnSelectedIndexChanged="lbxOrg_SelectedIndexChanged" 
 
Width="300px">  
 
</asp:ListBox> 
 
<br /> 
 
<asp:ListBox ID="lbxContract" runat="server" AutoPostBack="True"   
 
OnSelectedIndexChanged="lbxContract_SelectedIndexChanged" Rows="10" SelectionMode="Multiple" 
 
Width="100px">  
 
</asp:ListBox> 
 
</ItemTemplate> 
 
</telerik:RadPanelItem> 
 
</Items> 
 
</telerik:RadPanelItem> 
 
</Items> 
 
</telerik:RadPanelBar> 
 

Thanks!
ashah

Steven
Top achievements
Rank 1
 answered on 16 Dec 2014
2 answers
45 views
What would be causing the following in the following image?  Why would the footer row be shifting to the right like that.
Shawn
Top achievements
Rank 1
 answered on 16 Dec 2014
9 answers
167 views
Hi,

I am trying to use Gantt Control to replace in my application where we already have similar control. Here are the few things that I would like to achieve using the Gantt Control

1. Add new column - like "assign to" where i could edit/assign the task in the popup using drop down (editing on double click)
2. Import the tasks from MS Project
3. Export to pdf/word/excel
4. Print

Please advise.

Thank you
Alan
Hristo Valyavicharski
Telerik team
 answered on 16 Dec 2014
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?