Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
149 views
On click of the AddNewRecordButton, i want to hide button and the table header. On click of the addNewrecord, i can successfully hide the delete button on each row but the addNewRecord button still is visible! Also how can I hide the header?

I have a grid as follows. Add new record is a template.
          this._RadGrid1.ID = "RadGrid1";
        this._RadGrid1.Skin = "WebBlue";
        this._RadGrid1.Width = Unit.Percentage(100);
        this._RadGrid1.GridLines = GridLines.None;
        this._RadGrid1.AllowSorting = true;
        this._RadGrid1.AllowFilteringByColumn = false;
        this._RadGrid1.ShowGroupPanel = false;
        this._RadGrid1.AutoGenerateColumns = false;
        this._RadGrid1.AutoGenerateDeleteColumn = false;
        this._RadGrid1.AllowPaging = false;
        this._RadGrid1.EnableLinqExpressions = false;
        this._RadGrid1.MasterTableView.NoMasterRecordsText = "There are no documents associated with this order / quote / proposal.";      
        this._RadGrid1.ClientSettings.Selecting.AllowRowSelect = false;
        this._RadGrid1.ClientSettings.EnableRowHoverStyle = true;
        this._RadGrid1.ClientSettings.EnablePostBackOnRowClick = false;
        this._RadGrid1.MasterTableView.DataKeyNames = new string[] { this._EntityDocumentumReferenceTable.EntityDocumentumReferenceIdColumn.ColumnName };           
 
        this._RadGrid1.NeedDataSource += RadGrid1_NeedDataSource;
        this._RadGrid1.ItemDataBound += RadGrid1_ItemDataBound;
        this._RadGrid1.ItemCommand += RadGrid1_ItemCommand;    
 
          if (ShowAdd)
        {
            this._RadGrid1.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = true;
            this._RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;               
            this._RadGrid1.MasterTableView.CommandItemSettings.AddNewRecordText = "Add Document";                          
            this._RadGrid1.MasterTableView.EditFormSettings.EditFormType = GridEditFormType.Template;
            this._RadGrid1.MasterTableView.EditFormSettings.FormTemplate = new AddDocumentTemplate(this._EntityId,
                       this._EntityType,
                       this._QuoteId,
                       this.CustomerNumber,
                       this.CompanyId,
                       this.ProposalNumber,
                       this.CatalogProductId);
        }
The ItemDataBound is as follows:
         private void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
       {        
           if (e.Item is GridDataItem)
           {            
               //Access the Insert Form, disable delete when in insert mode
              if (e.Item is GridEditableItem && !e.Item.IsInEditMode && e.Item.OwnerTableView.IsItemInserted)
              {
                  this._RadGrid1.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;                  
                  GridEditableItem insertItem = (GridEditableItem)e.Item;
                  ImageButton btnDelete = (ImageButton)dataItem["DeleteColumn"].Controls[0];
                  btnDelete.Visible = false;
                  //this._RadGrid1.ClientSettings.Selecting.AllowRowSelect = false;
              }
           } 
       }
Princy
Top achievements
Rank 2
 answered on 30 May 2014
11 answers
1.6K+ views
Hi,

can you tell me  how to change radgrid selected item style? When I use the following css, it appears that there's a grey overlay and blow there's the red background i'm looking for. I attached a photo to give you an example.
.SelectedStyle
{
 background-color: red !important;
}
<telerik:RadGrid ID="grdClients" runat="server" Width="100%" AutoGenerateColumns="false"
       AllowMultiRowEdit="false" ShowHeader="false" DataSourceID="objClients"
           CssClass="RadGrid_Default" SelectedItemStyle-CssClass="SelectedStyle">

Thanks
Shinu
Top achievements
Rank 2
 answered on 30 May 2014
4 answers
461 views
Hello,
When my users click the buttons on the grid forms the form takes a while to close.  I suspect, the users are clicking the button again, or even clicking another button on the form that also closes the form. I'm seeing that they sometimes create duplicate records.  I've tried to disable the button in javascript but the form doesn't close.  It does a postback and comes back with the button enabled.
Is there a way to achieve disabling a few buttons and still have the normal behaviour?
Joan
Top achievements
Rank 1
 answered on 30 May 2014
4 answers
371 views
Hi,

I'm having the weirdest problem with the RadUpload control.
I was trying to integrate the control in a fairly complicated aspx page and got the following error from Visual Studio (9.0.etc.) when running the page in debug mode:
"Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors.
Parameter name: element"
I tried to read up on this problem on the internet but couldn't make much sense of what is written on the subject.
So I decided to make a test page just for this control, following the instructions in the "RadControls for ASPNET AJAX Q1 2008 Documentation" (or at least for the larger part), to see how I could get it working.

And guess what? It worked!
So I started experimenting with renaming the uploaded file and stuff and it still worked. Up to a certain point...
The thing is I don't see what it was that caused a problem. To me it seems as if from one moment to the other it just stopped working.
Although the problem was not the same error. All of the sudden "rulMediaUpload.UploadedFiles[0]" became null all the time.

I grew tired of it yesterday so I dropped it for the day. This morning I decided to comment all lines but those with I think it was I started with when making the test page the first time, when it still worked. And now I'm stuck again with the "Value must not be null for Controls and Behaviors" error from Visual Studio...
I really can't see what the difference is between the code as it is this morning and yesterday morning (ignoring the commented lines) except that it did work yesterday!

This is the code in the aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RadUploadTest.aspx.cs" Inherits="CMS.Views.Tests.RadUploadTest" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script type="text/javascript">
    
      function pageLoad() {
      }
    
    </script>
</head>

<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        
        <!--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>-->
            <telerik:RadUpload runat="server"
                AllowedFileExtensions=".jpg,.jpeg,.gif,.png,.bmp,.aac,.mp3,.wav,.wma,.asf,.avi,.mov,.mp4,.mpg,.qt,.swf,.wmv"
                ControlObjectsVisibility="None" MaxFileInputsCount="1" MaxFileSize="5000000"
                TargetFolder="~\Upload\Media" ID="rulMediaUpload" />
            <!--<telerik:RadProgressManager ID="RadProgressManager1" Runat="server" />
            <telerik:RadProgressArea ID="RadProgressArea1" Runat="server" DisplayCancelButton="True" ProgressIndicators="TotalProgressPercent">
            </telerik:RadProgressArea>-->
                
            <asp:Button ID="Button1" runat="server" Text="submit" onclick="Button1_Click" />
        <!--</ContentTemplate>
        </asp:UpdatePanel>-->
    </div>
    </form>
</body>
</html>

And this is the code in the corresponding aspx.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace CMS.Views.Tests
{
    public partial class RadUploadTest : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //string defaultTempFileName= Path.Combine(GetPathFromBase("Upload\\Media"),"xxx.jpg");
            //DateTime d = DateTime.Now;
            //string s = "" + d.Year + d.Month.ToString().PadLeft(2, '0') + d.Day.ToString().PadLeft(2, '0') + d.Hour.ToString().PadLeft(2, '0') + d.Minute.ToString().PadLeft(2, '0');
            //string FinalFileName= Path.Combine(GetPathFromBase("Upload\\Media"),"final-"+s+".jpg");
            //rulMediaUpload.UploadedFiles[0].SaveAs(defaultTempFileName);
            //FileInfo uploadedFile = new FileInfo(defaultTempFileName);
            //uploadedFile.MoveTo(FinalFileName);
        }
    }
}

In both files the commented lines didn't cause any problems when not commented until... they did!

Please help me out here.


Brian Kowald
Top achievements
Rank 1
 answered on 29 May 2014
1 answer
97 views
Dear All,

      In my page , i'm having one radtreeview with a tabsrip. in that tab i'm having some controls like lable , texbox and a button for save the details. Once i will click on "save" button the details will be insert into appropriate table and the data will be shown in the treeview. 

    Here my problem  is, that if i will save the details, i'm unable to refresh / bind data into the radtreeview which is in parent page(aspx) from the tabstrip page(aspx).

    Assist me that how to access parent controls from the tabstrip page????
Nencho
Telerik team
 answered on 29 May 2014
3 answers
188 views
Hello,

We are having a problem with the grid not maintaining column width on postback when you set EnableViewState = false. If I enable the property it works. However, there are other problems that occur if we leave it enabled.

We were running on the last 2012 build up until now. I noticed in the 2013.1.220 release notes this: "Fixed:EnableViewState property of RadGrid does not turn off the ViewState of RadGrid instance”. And according to this documentation http://www.telerik.com/help/aspnet-ajax/grid-viewstate-optimization.html, various column properties are maintained even with the property set to false.

To recreate the problem all you need to do is create a declarative grid and set EnableViewState=false and hookup the onColumnResize event to postback. 

Also, if you reorder columns first and then resize a column, the order will reset.

Any help would be appreciated.

Blair
Maria Ilieva
Telerik team
 answered on 29 May 2014
12 answers
470 views

I have a DatePicker in a RadGrid defined as follows:

<telerik:GridTemplateColumn HeaderText="Birthdate" UniqueName="scout_dob">  
    <ItemStyle Width="75" /> 
    <ItemTemplate> 
        <asp:Label Width="70" CssClass="gridLabel" runat="server" ID="lbl_scout_dob" Text='<%# Eval("scout_dob_new") %>' /> 
    </ItemTemplate> 
    <EditItemTemplate>                              
        <telerik:RadDatePicker Width="70" ID="dp_scout_dob" Style="vertical-align: middle;" SelectedDate='<%# Bind("scout_dob") %>' runat="server">  
            <DatePopupButton Visible="False"></DatePopupButton> 
            <DateInput onclick="scoutDOBPopup()" runat="server" /> 
        </telerik:RadDatePicker> 
    </EditItemTemplate> 
</telerik:GridTemplateColumn> 

I cannot seem to get the calendar to popup on clicking the date box. The problem is I can't seem to find the ClientID of the DatePicker. Using <%= dp_scout_dob.ClientID %> either in a $find command in the JavaScript or passing it in the onclick event both return NULL. I even tried to figure out the actual elementID and use a getElementByID command in the JavaScript, but I couldn't seem to figure out what the actual ClientID is.

Can someone point me in the right direction? Either help me figure out how to reference the ClientID or what the actual full ClientID is if this control is inside a RadGrid? Thanks.
Sam
Top achievements
Rank 1
 answered on 29 May 2014
2 answers
121 views
Hi all I have Grid having Child grids inside it and am implementing select / deselect all functionality on it it is  working but when I collapse any grid then the record of  that grid getting selected too . Please help me out on that I have used a hiddenfield to keep the client id of  all checkbox against each record. on Item data bound event.  please look in to  the code below Let me knoew What else I  can try.


<%@ Page Language="C#" MasterPageFile="~/MasterPages/Default.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs"  Inherits="MainClass"
    Title="Vendor Returns" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder_Content" runat="Server">
    <telerik:RadScriptBlock ID="ItemsRadScriptBlock" runat="server">
        <script type="text/javascript">
           
            var registeredElements = [];
            var selectDeselectAllFlag = true;

            function GetRegisteredServerElement() {
                try {
                    var clientIDs = document.getElementById('CheckboxIDsHiddenField').value;
                    var inputList = clientIDs.split(',');
                    var clientID = "";
                    alert(inputList.length);
                    for (var i = 0; i < (inputList.length) ; i++) {
                        clientID = inputList[i];
                        var checkbox = document.getElementById(clientID);
                        if (checkbox) {
                            checkbox.checked = selectDeselectAllFlag;
                        }
                    }
                    selectDeselectAllFlag = !selectDeselectAllFlag;
                    return true;
                }
                catch (er) {
                }
            }
            

        </script>
    </telerik:RadScriptBlock>
    <telerik:RadSplitter ID="splitterMain" runat="server">
        <telerik:RadPane ID="panetop" runat="server" SkinID="TopRadPane" Height="80px">
        </telerik:RadPane>
        <telerik:RadSplitBar ID="RadSplitBar1" runat="server">
        </telerik:RadSplitBar>
        <telerik:RadPane ID="panebottom" runat="server" SkinID="BottomRadPane" Scrolling="Both">
            <asp:Label ID="MessageLabel" runat="server" SkinID="MessageLabel" Visible="false"></asp:Label>
            <table width="100%">
                <tr>
                    <td>
                        <div class="RadGridHorizontalScroll" style="width: auto" id="RadGridTableContainer">
                            <telerik:RadGrid ID="RadGrid" runat="server" OnItemDataBound="RadGrid_ItemDataBound"
                                OnNeedDataSource="RadGrid_NeedDataSource" OnDetailTableDataBind="RadGrid_DetailTableDataBind"
                                OnItemCreated="RadGrid_ItemCreated">
                                <ClientSettings>
                                    <Selecting AllowRowSelect="True"></Selecting>
                                    <Resizing AllowColumnResize="true" EnableRealTimeResize="true" ResizeGridOnColumnResize="true"
                                        ClipCellContentOnResize="true" />
                                </ClientSettings>
                                <MasterTableView  CommandItemDisplay="Top" HorizontalAlign="left"
                                    Name="Vendors" HierarchyDefaultExpanded="True" HierarchyLoadMode="Client">
                                    <CommandItemTemplate>
                                        <table class="ContentPaddingLeft">
                                            <tr>
                                                <td class="ButtonSeparator">
                                                    <asp:LinkButton ID="SelectDeselectAllLinkButton" runat="server" OnClientClick="return GetRegisteredServerElement();"
                                                        Text="Select / Deselect All" SkinID="SmallCommandItemTemplateLinkButton"></asp:LinkButton>
                                                </td>
                                            </tr>
                                           
                                        </table>
                                    </CommandItemTemplate> 
                                    <Columns>
                                        <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                    <ExpandCollapseColumn Visible="False">
                                        <HeaderStyle Width="19px" />
                                    </ExpandCollapseColumn>
                                    <RowIndicatorColumn Visible="False">
                                        <HeaderStyle Width="20px" />
                                    </RowIndicatorColumn>
                                    <DetailTables>
                                        <telerik:GridTableView runat="server" DataKeyNames="VendorID,PartID" Name="VendorReturns"
                                           AllowMultiColumnSorting="true" EnableViewState="true" BorderWidth="1">
                                            <ExpandCollapseColumn Visible="True">
                                            </ExpandCollapseColumn>
                                            <Columns>
                                                <telerik:GridTemplateColumn UniqueName="ShowEditColumn" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Left"
                                                    HeaderText="" Resizable="false" Reorderable="false" ItemStyle-Width="25px" HeaderStyle-Width="85px">
                                                    <ItemTemplate>
                                                        <table style="white-space: nowrap">
                                                            <tr>
                                                                <td style="border: white">
                                                                    <asp:CheckBox ID="AllowCheckBox" runat="server" />
                                                                    <telerik:RadScriptBlock ID="VendorReturnRadScriptBlock" runat="server">
                                                                        
                                                                    </telerik:RadScriptBlock>
                                                                </td>
                                                                <td style="border: white">
                                                                    <asp:LinkButton ID="EditLinkButton" Text="Edit" runat="server" SkinID="SmallLinkButton"></asp:LinkButton>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </ItemTemplate>
                                                    <ItemStyle Wrap="true" Width="10px" />
                                                </telerik:GridTemplateColumn>
                                                Some other Columns are  here
                                            </Columns>
                                        </telerik:GridTableView>
                                    </DetailTables>
                                </MasterTableView>
                            </telerik:RadGrid>
                        </div>
                        <telerik:RadAjaxManagerProxy ID="radAjaxProxyManager" runat="server">
                        </telerik:RadAjaxManagerProxy>
                        <telerik:RadAjaxLoadingPanel ID="radAjaxLoadingPanel" runat="server" />
                    </td>
                </tr>
            </table>
        </telerik:RadPane>
    </telerik:RadSplitter>
    <asp:HiddenField runat="server" ID="CheckboxIDsHiddenField" ClientIDMode="static" />
</asp:Content>

And My CS file is as 
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Security;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Text;

public partial class MainClass : PageHandler
{
    #region Declarations
    String clientid = String.Empty;
    StringBuilder _clientIDs = new StringBuilder();

   

    #endregion

    #region Event Handlers

    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (_selectDeselectAllLinkButton != null )
        {
            _selectDeselectAllLinkButton.Enabled = _isChildExist;
        }
        if (_expandCollapsAllLinkButton != null)
            _expandCollapsAllLinkButton.Enabled = _isRowExist;

        AlignRadComboBoxTextLeft(Page);
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        AddCustomPager(RadGrid);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        MessageLabel.Visible = false;
       
        
        RadAjaxManager radAjaxManager = RadAjaxManager.GetCurrent(Page);
        radAjaxManager.AjaxSettings.AddAjaxSetting(radAjaxManager, CheckboxIDsHiddenField);
        radAjaxManager.AjaxSettings.AddAjaxSetting(radAjaxManager, RadGrid);
        radAjaxManager.AjaxSettings.AddAjaxSetting(RadGrid, CheckboxIDsHiddenField);
        radAjaxManager.AjaxSettings.AddAjaxSetting(RadGrid, MessageLabel);
       
    }

  

   

    protected void RadGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        try
        {
            if (e.Item is GridCommandItem)
            {
                _selectDeselectAllLinkButton = e.Item.FindControl("SelectDeselectAllLinkButton") as LinkButton;
                _expandCollapsAllLinkButton = e.Item.FindControl("ExpandCollapsAllLinkButton") as LinkButton;
            }

            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = e.Item as GridDataItem;
                if (dataItem != null)
                {
                    CheckBox selectCheckBox = dataItem.FindControl("AllowCheckBox") as CheckBox;
                    if (selectCheckBox != null)
                    {
                        clientid = selectCheckBox.ClientID;
                        _clientIDs.Append(clientid);
                        _clientIDs.Append(",");
                    }
                }
                _isRowExist = true;
               
            if (e.Item is GridFooterItem)
            {
                if (_clientIDs.ToString().Length > 0)
                {
                    String clientIDs = _clientIDs.ToString(0, _clientIDs.ToString().Length - 1);
                    CheckboxIDsHiddenField.Value = clientIDs;
                }
            }
        }
        catch (SecurityException ex)
        {
            ExceptionHandler exceptionHandler = new ExceptionHandler(MessageLabel);
            exceptionHandler.HandleException(ex);
        }
        catch (DataPortalException ex)
        {
            ExceptionHandler exceptionHandler = new ExceptionHandler(MessageLabel);
            exceptionHandler.HandleException(ex);
        }
        
    }

   

  

    protected void ExpandCollapsAllLinkButton_Click(object sender, EventArgs e)
    {
        foreach (GridDataItem gridItems in RadGrid.MasterTableView.Items)
        {
            gridItems.Expanded = _flag;
        }
        _flag = !_flag;
    }

    protected void UserStoreroomRadComboBox_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        
        RadGrid.Rebind();
    }

   

    #endregion

    #region Class Functions

    }

    #endregion
}  

Please help me as  soon as possible . Thanks in Advance


Angel Petrov
Telerik team
 answered on 29 May 2014
1 answer
596 views
Hello,

I'm currently working on a project with RadGrid.

In my grid I have the first column GridClientSelectColumn (Checkbox).

VB.NET Code:
'add check box column
            Dim objGridClientSelectColumn As GridClientSelectColumn = New GridClientSelectColumn()
            objGridClientSelectColumn.UniqueName = "UniqMainGrid"
            RadGrid1.MasterTableView.Columns.Add(objGridClientSelectColumn)


When I click "Select all", all the rows on the same page are selected.

What I need is that when I clicked "Select All / Select None" it will "Select / Un-select"
all rows in all pages.


Thanks in advance,

Daniel.



Princy
Top achievements
Rank 2
 answered on 29 May 2014
2 answers
109 views

Hi,

Could you show me how to get the innertext (company_name) from the legend in the ItemCommand event?  I tried the following, but the error is object reference not set.

Here's the partial code that shows the legend:
1.<ItemTemplate>
2.    
3.        <fieldset style="float:left; width: 480px; height:280px; margin:5px; ">
4. 
5.            <legend ID="companyName" style="color:darkblue; font-weight:bold">
6.                      <%#Eval("company_name")%><img src="../../images/new1.png" style="width:15px;height:15px" />
7.            </legend>

Here's the code-behind

01.protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
02.{
03.    // TODO: need to pass leadid to main.
04.    if (e.CommandName == "OpenDetail")
05.    {
06.        RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
07.        string leadId = item.GetDataKeyValue("lead_id").ToString();
08. 
09.        //Label websitelabel = item.FindControl("WebsiteLabel") as Label;  // ** accesss ok **//
10.         
11.        // ** object reference not set **//
12.        string leadName = (item.FindControl("companyName") as System.Web.UI.HtmlControls.HtmlGenericControl).InnerText;
13. 
14.        // ** Not working **//
15.        //Hashtable table = new Hashtable();
16.        //item.OwnerListView.ExtractValuesFromItem(table, item, true);
17.        //string leadName = table["CompanyLegend"].ToString();
18.        //string leadName = "ABC";
19. 
20.        OutcomeEventArgs outcomeEventArgs = new OutcomeEventArgs(leadId, leadName);
21.        if (OpenLeadDetail != null)
22.            OpenLeadDetail(this, outcomeEventArgs);
23.    }
24. 
25.}

Thank you,

Helen

Helen
Top achievements
Rank 1
 answered on 29 May 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?