Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
169 views
How do I get the menu text of the menu item selected with client side code?

Thanks
Aneliya Petkova
Telerik team
 answered on 16 Dec 2014
1 answer
275 views
I have a radgrid that 1. I cannot highlight the row on clicking and 2. the selectedindexchanged event does not fire.  The grid sits inside an update panel and is loaded when a user select a value from a combo box, which is passed as a parameter to a stored procedure.  The grid load without problem, but as mentioned once loaded I cannot click on the row and highlight the row and the selectedindexchanged event does not fire.  Below is the grid settings.  I have also tried  to add the following code on the page load, but this has not helped.
 this.grdItems.ClientSettings.EnablePostBackOnRowClick = true;
this.grdItems.ClientSettings.Selecting.AllowRowSelect = true;

Any suggestions?

<telerik:RadGrid ID="grdItems" runat="server" CellSpacing="0"
                                      DataSourceID="SqlDataSource1" GridLines="None" Height="400px"
                                      AccessKeySkin="Office2010Black"
                                         onselectedindexchanged="grdItems_SelectedIndexChanged"
                                         Skin="Office2010Black">
                                         <clientsettings>
                                          <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                                       <ClientEvents OnRowSelected="RowSelected" />
                                          <selecting AllowRowSelect="True" />
                                        </clientsettings>
                                        <mastertableview allowpaging="True" autogeneratecolumns="False"
                                         datakeynames="ID" datasourceid="SqlDataSource1" pagesize="14">
                                         <Columns>
                                            <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" Display="False"
                                             FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True"
                                             SortExpression="ID" UniqueName="ID">
                                             </telerik:GridBoundColumn>
                                             <telerik:GridBoundColumn DataField="HoseID"
                                              FilterControlAltText="Filter HoseID column" HeaderText="Hose ID"
                                              ReadOnly="True" SortExpression="HoseID" UniqueName="HoseID">
                                              <HeaderStyle Font-Bold="True" Font-Size="Larger" />
                                             </telerik:GridBoundColumn>
                                         </Columns>
                                      </mastertableview>
                                     </telerik:RadGrid>
Konstantin Dikov
Telerik team
 answered on 16 Dec 2014
4 answers
97 views
Hi Telerik, 

I posted a thread a couple of days ago and I thought I had solved my problem but turns out I just moved it.

My problem now is that I have template columns that contain buttons and others that have text that needs to be on a different color depending on the status of the item.

So basically, I used to bind my grid using the 'simple way' (Create data table, add source to the grid and bind)
Once it was bound, I would go through each rows, set the text to the button and set the appropriate CSS on the text label. 

Since I needed to sort and to filter, I saw that I could use the 'OnNeedDataSource' event, which is the second way to bind a grid.

This worked and I could sort/filter my grid.

But now, after the event is called, I tried to change the CSS and the text again but it says that the grid doesnt have any items.

I believe its because it wasnt bound (even though I can see the rows once everything is done)



Eyup
Telerik team
 answered on 16 Dec 2014
1 answer
79 views
Hi,

If I use a grid smart tag to edit the EditTemplate and drag a control into the edit box provided, it produces this code in <MasterTableView>:

<EditItemTemplate>
    <asp:Button ID="Button1" runat="server" Text="Button" />
</EditItemTemplate>

but when my template opens it shows nothing, basically just a title bar with no content. When I use the code below (which I got from your website) then the template shows up just fine - so just what is EditItemTemplate all about?

<EditFormSettings EditFormType="Template">
    <PopUpSettings Modal="True" />
    <FormTemplate>
        <telerik:RadTextBox ID="Username" Runat="server">
        </telerik:RadTextBox>
    </FormTemplate>
</EditFormSettings>
Eyup
Telerik team
 answered on 16 Dec 2014
1 answer
64 views
Good morning.

This is my first post, so I will do my best to cover everything as thoroughly as possible. I am implementing a RadGrid in an ASP.NET project. Here are the particulars:

Windows 7
IE 11
ASP.NET 4.5
preferred language is VB
latest version of Telerik Tools

I have followed the instructions of several examples I've found online, including some here, but to no avail. No matter what I do, when I click any button in my RadGrid - Add, Edit, Cancel, etc. I get a PostBack. After clicking any button, all subsequent attempts to interact with the RadGrid fail due to the postback. I just want to use AJAX. Here is my RadGrid code:

<telerik:RadGrid ID="attachment_list" runat="server"
    OnNeedDataSource="attachment_list_NeedDataSource"
    AutoGenerateColumns="False"
    AllowPaging="True"
    PageSize="30"
    AllowAutomaticDeletes="True"
    AllowAutomaticInserts="True"
    AllowAutomaticUpdates="True"
    OnEditCommand="attachment_list_EditCommand"
    GroupPanelPosition="Top" >           
    <HeaderContextMenu EnableAutoScroll="True"
    </HeaderContextMenu
    <MasterTableView                    
        CommandItemDisplay="Top"
        NoMasterRecordsText="There are currently no attachments">
        <CommandItemSettings AddNewRecordText="Attach Another File" />                        
        <RowIndicatorColumn
            <HeaderStyle Width="20px"></HeaderStyle
        </RowIndicatorColumn
        <ExpandCollapseColumn
            <HeaderStyle Width="20px"></HeaderStyle
        </ExpandCollapseColumn>
        <NoRecordsTemplate>
            <div ID="no_data_label">There are currently no attachments</div>
        </NoRecordsTemplate
        <Columns
            <telerik:GridBoundColumn DataField="AttachmentPath" HeaderText="File Name" UniqueName="FileName" ItemStyle-Width="340px">  
            </telerik:GridBoundColumn
            <telerik:GridBoundColumn DataField="AttachmentDescriptors" HeaderText="Description" UniqueName="Desc" ItemStyle-Width="450px">  
            </telerik:GridBoundColumn>                       
            <telerik:GridBoundColumn DataField="LastUpdatedDate" HeaderText="Updated Date" UniqueName="UpdatedDate" ItemStyle-Width="200px">  
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="UpdatedByName" HeaderText="Updated By" UniqueName="UpdatedBy" ItemStyle-Width="200px">  
            </telerik:GridBoundColumn>                                                     
            <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this item?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete"
                ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                <ItemStyle HorizontalAlign="Center" CssClass="delete_button"></ItemStyle>
            </telerik:GridButtonColumn>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                <ItemStyle CssClass="edit_button"></ItemStyle>
            </telerik:GridEditCommandColumn>                   
        </Columns>
                 
        <EditFormSettings EditFormType="Template">
            <FormTemplate>
                <asp:Panel ID="attachment_edit" runat="server" GroupingText='<%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "Add an Attachment", "Update an Attachment")%>'>
                    <div class="inner_1">
                        <div class="float_left">
                            <asp:Panel ID="att_file_wrapper" runat="server">
                                <div class="label">Select File:</div>               
                                <telerik:RadUpload ID="att_file" runat="server" ReadOnlyFileInputs="True" ControlObjectsVisibility="none" ></telerik:RadUpload>
                            </asp:Panel>
                            <div class="label">Description:</div><asp:TextBox ID="att_desc" runat="server" Text='<%# Bind("AttachmentDescriptors")%>'></asp:TextBox>                                  
                        </div>                                   
                    </div>
                </asp:Panel>
 
                <div class="btn_group_small">
                    <asp:Button runat="server" ID="add_task" Text='<%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "Add Attachment", "Update Attachment")%>'
                        CommandName='<%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "Insert", "Update")%>' CssClass="small_btn" />
                    <asp:Button runat="server" ID="cancel_task" Text="Cancel" CommandName="Cancel"
                        CausesValidation="False" CssClass="small_btn" />
                </div>
 
            </FormTemplate>
        </EditFormSettings>                
    </MasterTableView>                       
</telerik:RadGrid>

Here is my Ajax Manager code (my primary RadAjaxManager is in the Matser page):

<telerik:RadAjaxManagerProxy ID="AjaxManagerProxy1" runat="server" >
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="attachment_list">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="attachment_list" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>                      
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

I am fairly new to using Telerik (and .NET in general), and I'm on a tight deadline. Any assistance would be appreciated - thanks.
Maria Ilieva
Telerik team
 answered on 16 Dec 2014
1 answer
89 views
Respected Sir/M'am,

we are currently facing an issue in RadAsyncUpload where :
1)  After the file is uploaded, if any postback occurs (may it

be a cancel button postback or any other control postback) the

uploaded file is directly moved to the target folder



Is there any solution where on specified control click only ,

the uploaded file can be moved to target folder else it will

persist as it is uploaded.


Regards,
GIPL Team
Hristo Valyavicharski
Telerik team
 answered on 16 Dec 2014
1 answer
82 views
I have set the number of rows per page to 15.  When I have fewer than 15 rows the footer is not displayed.  When I have more than 15 row the footer is displayed with the various counts and navigation buttons are displayed.  ( Page 1 of 34, items 1 to 15 of 500)  My client wants the footer displayed when less than 15 records and have a count  something like the following.   (Page 1 of 1, items 1 to 10 of 10)  I defined my grid as follows.

            RadGrid1.ID = "RadGrid1";
            RadGrid1.DataSourceID = "SqlDataSource1";
            RadGrid1.MasterTableView.DataKeyNames = new string[] { "Jobnumber" };
            RadGrid1.Skin = Theme;
            RadGrid1.EnableEmbeddedSkins = false ;
            RadGrid1.Width = Unit.Percentage(100);
            RadGrid1.PageSize = 15;
            RadGrid1.AllowPaging = true;
            RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrev;
            RadGrid1.AllowSorting = true;
            RadGrid1.AllowFilteringByColumn = false;
            RadGrid1.AutoGenerateColumns = false;
            RadGrid1.ClientSettings.Resizing.AllowColumnResize = true;
            RadGrid1.ClientSettings.Resizing.ResizeGridOnColumnResize = true;
            RadGrid1.ClientSettings.Resizing.ClipCellContentOnResize = true;
            RadGrid1.ClientSettings.AllowColumnsReorder = true;
            RadGrid1.ClientSettings.ColumnsReorderMethod = GridClientSettings.GridColumnsReorderMethod.Reorder;
            RadGrid1.GridLines = GridLines.Both;
            
            RadGrid1.EnableViewState = true; 

            
            RadGrid1.ItemCommand += new GridCommandEventHandler(RadGrid1_ItemCommand);
            RadGrid1.PageIndexChanged += new GridPageChangedEventHandler(RadGrid1_PageIndexChanged);

Pavlina
Telerik team
 answered on 16 Dec 2014
1 answer
112 views
Hi,

I have a radgrid in which i have placed the following controls
1)A RadTabstrip -with 2 pageviews (one for displaying a page and the another for displaying someother page)
2)someother page may not be visible based on the functionality most of the times. so i am checking for its visibility in itemcreated.
if visible false do not display the page 2
on clicking the expand collapse button it should expand /collapse the radgrid displaying the tabstrip.
3)added to this i have a validation in prerender event of the radgrid which has some validations as follows. means it reorders some columns and based on a condition makes few columns visible or not visible.

Here is the radgrid prerender event.
    protected void RadGrid1_PreRender(object sender, EventArgs e)
        {
            DataTable dtVerbatimColums = VerbatimGridSource;
            int neworderindex = 4;
            for (int i = 0; i < dtVerbatimColums.Rows.Count; i++)
            {
                if (dtVerbatimColums.Rows[i]["Label"].ToString() == "Default")
                {
                    try
                    {
                        RadGrid1.Columns.FindByUniqueName(dtVerbatimColums.Rows[i]["ID"].ToString()).OrderIndex = neworderindex++;
                    }
                    catch (GridException)
                    {
                        continue;
                    }
                }
                else
                {
                    try
                    {
                        RadGrid1.Columns.FindByUniqueName(dtVerbatimColums.Rows[i]["Label"].ToString()).OrderIndex = neworderindex++;
                    }
                    catch (GridException)
                    {
                        continue;
                    }

                }
            }
          
            if (RadGrid1.MasterTableView.GetColumn("ActionNotes") != null)
            {
                RadGrid1.MasterTableView.GetColumn("ActionNotes").HeaderText = VS.VerbatimOptions.TextActionsWindow;
                RadGrid1.MasterTableView.GetColumn("ActionNotes").Visible = VS.VerbatimOptions.ShowActionsWindow;
            }
            if (RadGrid1.MasterTableView.GetColumn("AppealStatus") != null)
            {
                RadGrid1.MasterTableView.GetColumn("AppealStatus").Visible = VS.VerbatimOptions.ShowAppeal;
            }
            if (RadGrid1.MasterTableView.GetColumn("Evaluate") != null)
            {
                RadGrid1.MasterTableView.GetColumn("Evaluate").Visible = VS.VerbatimOptions.ShowAppeal;
            }
            RadGrid1.Rebind();
            foreach (GridDataItem item in RadGrid1.Items)
            {

                //Column Download
                CheckBox cbAvailable = item["Download"].FindControl("chAvailable") as CheckBox;
                CheckBox cbHeadAvailable = item["Download"].FindControl("chAvailable") as CheckBox;
                if (cbAvailable != null)
                {

                    cbAvailable.Checked = IsItemChecked(Convert.ToInt32(item["id"].Text));
                    RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbAvailable, cbAvailable);
                    RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbAvailable, RadGrid1);

                    RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbHeadAvailable, cbHeadAvailable);
                    RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbHeadAvailable, RadGrid1);
                }
                string decodedText = "";
                string encodedText = "";
                // Check for empty transcription - if is it empty, remove all controls from cell and replace it with empty text, to avoid missing left and bottom cell border
                if (RadGrid1.Columns.FindByUniqueName("Transcription").Visible)
                {
                    GridTableCell cell = item["Transcription"] as GridTableCell;
                    Label textControl = cell.Controls[1] as Label;
                    if (string.IsNullOrEmpty(textControl.Text))
                    {
                        item["Transcription"].Controls.Clear();
                        item["Transcription"].Text = "&nbsp;";
                    }
                    else
                    {
                        //added 28-Oct-2014
                        decodedText = Server.HtmlDecode(textControl.Text);                  //decode everything back first
                        encodedText = System.Security.SecurityElement.Escape(decodedText);  //encode back only < > " ' & before outputting
                        //encodedText2 = Server.HtmlEncode(decodedText);

                        //item["Transcription"].Text = DescriptionTrunc(Server.HtmlEncode(decodedText));  //html encode output
                        //item["Transcription"].ToolTip = Server.HtmlEncode(decodedText);                 //html encode output

                        //added 28-Oct-2014
                        item["Transcription"].Text = DescriptionTrunc(encodedText);
                        item["Transcription"].ToolTip = encodedText;
                    }

                }

                if (!item["Type"].Text.Contains("V"))
                {
                    item["Play"].Controls.Clear();
                    item["Play"].Text = "&nbsp;";
                }
                else
                {
                    string fileName = item["FileName"].Text;
                    ImageButton ib = item["Play"].Controls[1] as ImageButton;
                    if (ib == null) continue;

                    //Verbatim file check
                    if (fileName != string.Empty)
                    {
                        string path = VerbatimManager.GetVerbatimFilePath(fileName);
                        if (!File.Exists(path))
                        {
                            item["Play"].Controls.Clear();
                            item["Play"].Text = "&nbsp;";
                            item["FileName"].Enabled = false;
                            continue;
                        }
                    }

                    //Permission check
                    if (!user.IsAuthorized(PermissionNames.Security_Verbatim_PlayVerbatim))
                    {
                        ib.Enabled = false;
                        continue;
                    }

                    //Play button tooltip
                    if (fileName != "")
                    {
                        ib.ToolTip = user.Translate("VerbatimResponses.Play") + " " + VerbatimManager.GetVerbatimFilePath(fileName);
                        ib.CommandArgument = fileName;
                        RadAjaxManager1.AjaxSettings.AddAjaxSetting(ib, ib);
                    }

                    if (!isPPTExport)
                    {
                        ib.Attributes.Add("OnMouseOver", "src='Images/play_over.gif';");
                        ib.Attributes.Add("OnMouseOut", "src='Images/play.gif';");
                    }
                    else
                    {
                        ib.Attributes.Add("src", "play.gif");
                    }
                    ib.AlternateText = user.Translate("VerbatimResponses.Play");
                }


                // 20141030
                if (item["AppealStatus"].Text.Contains("Pending"))
                {
                    item["AppealStatus"].ForeColor = System.Drawing.Color.Navy;
                }
                else if (item["AppealStatus"].Text.Contains("Approved"))
                {
                    item["AppealStatus"].ForeColor = System.Drawing.Color.Green;
                }
                else if (item["AppealStatus"].Text.Contains("Declined"))
                {
                    item["AppealStatus"].ForeColor = System.Drawing.Color.Red;
                }
            }
        }

Item Command Event of the radgrid.
 //To make the tab page visible   
            RadPageView ExplorePageView;
            RadPageView EvaluatePgView;
            RadTabStrip rdtabexploreeval;


            if (e.CommandName == "RowClick" || e.CommandName == "ExpandCollapse")
            {



            //if (e.CommandName == RadGrid.ExpandCollapseCommandName && e.Item is GridDataItem)
            //{
                GridDataItem gridFormItem = e.Item as GridDataItem;
                int VerbatimId = int.Parse(gridFormItem["id"].Text);

                string sessionId = gridFormItem["SessionId"].Text;

                string exploreurl = "VerbatimExplore.aspx?SessionId=" + sessionId + "&VerbatimId=" + VerbatimId + "&ActionName=Explore";
                string evaluateurl = "VerbatimExplore.aspx?SessionId=" + sessionId + "&VerbatimId=" + VerbatimId + "&ActionName=Evaluate";
                foreach (GridNestedViewItem item in radgrid1.MasterTableView.GetItems(GridItemType.NestedView))
                {
                    ExplorePageView = (RadPageView)item.FindControl("radExplorePgView");
                    ExplorePageView.ContentUrl = exploreurl;
                    rdtabexploreeval = (RadTabStrip)item.FindControl("rdtabexploreeval");
                    rdtabexploreeval.Tabs[0].Text = user.Translate("VerbatimResponses.Explore");
                    rdtabexploreeval.Tabs[1].Text = user.Translate("verbatimResponses.evaluate");
                    EvaluatePgView = (RadPageView)item.FindControl("radEvalPgView");
                    EvaluatePgView.ContentUrl = evaluateurl;

                }
                bool lastState = e.Item.Expanded;

                if (e.CommandName == "ExpandCollapse")
                {
                    lastState = !lastState;
                }
                CollapseAllRows();
                e.Item.Expanded = !lastState;
        }
           

                if (e.CommandName.ToUpper() != "PLAY") return;
                string fileName;
                fileName = GetFileToDownload(e.CommandArgument.ToString());

            // Added code by Raguraman on 12-DEC-2011 for VSMD-4612            

            if (!VS.VerbatimOptions.PlayVerbatimInNewBrowserPage)
            {
                SetDownloadButtons();
                if (fileName != "")
                {
                    verbatimManager.SetLastDownload(int.Parse(radgrid1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["id"].ToString()));
                    Misc.DownloadWavToResponse(fileName);
                }
            }

            // END  RadTabStrip rdtabexploreeval;
            RadPageView EvaluatePgView;
            //RadPageView ExplorePgView;
            if (e.Item.Expanded == true)
            {
                e.Item.PreRender += new EventHandler(radgrid1_PreRender);
            }
            if (RadGrid1.MasterTableView.GetColumn("Evaluate") != null)
            {
                //switch off the evaluate tab strip visible false if showappeal is set to false.
                if (VS.VerbatimOptions.ShowAppeal ==false)
                
                {
                    foreach (GridNestedViewItem item in Radgrid1.MasterTableView.GetItems(GridItemType.NestedView))
                    {                
                        rdtabexploreeval = (RadTabStrip)item.FindControl("rdtabexploreeval");
                        EvaluatePgView = (RadPageView)item.FindControl("radEvalPgView");
                        rdtabexploreeval.Tabs[1].Visible = false;
                    }
                }
            }
Item created event of the radgrid.

RadTabStrip rdtabexploreeval;
            RadPageView EvaluatePgView;
            //RadPageView ExplorePgView;
            if (e.Item.Expanded == true)
            {
                e.Item.PreRender += new EventHandler(RadGrid1_PreRender);
            }
            if (RadGrid1.MasterTableView.GetColumn("Evaluate") != null)
            {
                //switch off the evaluate tab strip visible false if showappeal is set to false.
                if (VS.VerbatimOptions.ShowAppeal ==false)
                
                {
                    foreach (GridNestedViewItem item in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView))
                    {                
                        rdtabexploreeval = (RadTabStrip)item.FindControl("rdtabexploreeval");
                        EvaluatePgView = (RadPageView)item.FindControl("radEvalPgView");
                        rdtabexploreeval.Tabs[1].Visible = false;
                    }
                }
            }

The aspx page has this line of code onprerender="radgrid1_prerender"". my problem is i am not expand or collapse. more over i get this error "controls cannot be modified outside the collection"". please help.
-Thanks
Gayathri
Viktor Tachev
Telerik team
 answered on 16 Dec 2014
19 answers
740 views
It would be great if you update the demo at http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx with a possibility to remove the new rows. Currently, the only way to do it is to cancel all updates.
Pavlina
Telerik team
 answered on 16 Dec 2014
1 answer
730 views
I'm attempting to create a wizard with an unknowable number of steps and outcomes.  Steps are being created dynamically in code-behind based on user responses. I'm able to retrieve data from the wizard at completion and render my results correctly.  If a user walks through the wizard in a linear way everything functions, but when users step back through the wizard via the previous button I need to trap this condition to prevent logic from re-running and creating duplicates of steps that already exist.

My question is - is there any absolute way to reference a particular step (i.e. step.ID) so I can check to see what step a user is leaving and what step a user is heading to? CurrentStepIndex is not usable since a user can arrive at a step from many different logical paths.
Plamen
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?