Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
140 views
I am programmatically adding columns to the RadGrid.
The problem is, after a postback (when say expanding the grid even though there is no code to populate data for the next level down hierarchy), the heading columns are gone.

any ideas why?

I also need to state that, should there be a postback from a column, which will be added in the future, that I need to obtain the modified row column values also.

protected void Page_Load(object sender, EventArgs e)
        {
            this.DoSetDefaultMenuColumns();
        }
 
        private void DoSetDefaultMenuColumns()
        {
            // lets create the columns.
            GridBoundColumn menuIDColumn = new GridBoundColumn();
            menuIDColumn.HeaderText = "Menu ID";
            menuIDColumn.DataField = "MenuID";
 
            GridBoundColumn menuNameColumn = new GridBoundColumn();
            menuNameColumn.HeaderText = "Menu Name";
            menuNameColumn.DataField = "MenuName";
 
            GridDropDownColumn menuOrderColumn = new GridDropDownColumn();
            menuOrderColumn.HeaderText = "Menu Order ID";
            menuOrderColumn.DataField = "MenuOrderID";
 
            GridDropDownColumn parentIDColumn = new GridDropDownColumn();
            parentIDColumn.HeaderText = "Parent ID";
            parentIDColumn.DataField = "ParentID";
 
            GridCheckBoxColumn isAdminColumn = new GridCheckBoxColumn();
            isAdminColumn.HeaderText = "Is Admin";
            isAdminColumn.DataField = "IsAdmin";
 
            GridBoundColumn pageURLColumn = new GridBoundColumn();
            pageURLColumn.HeaderText = "Page URL";
            pageURLColumn.DataField = "PageURL";
 
            GridCheckBoxColumn employeeAccessColumn = new GridCheckBoxColumn();
            employeeAccessColumn.HeaderText = "Employee Access";
            employeeAccessColumn.DataField = "EmployeeAccess";
 
            GridCheckBoxColumn customerAccessColumn = new GridCheckBoxColumn();
            customerAccessColumn.HeaderText = "Customer Access";
            customerAccessColumn.DataField = "CustomerAccess";
 
            this.radGridMenus.MasterTableView.Columns.Add(menuIDColumn);
            this.radGridMenus.MasterTableView.Columns.Add(menuNameColumn);
            this.radGridMenus.MasterTableView.Columns.Add(menuOrderColumn);
            this.radGridMenus.MasterTableView.Columns.Add(parentIDColumn);
            this.radGridMenus.MasterTableView.Columns.Add(pageURLColumn);
            this.radGridMenus.MasterTableView.Columns.Add(isAdminColumn);
            this.radGridMenus.MasterTableView.Columns.Add(employeeAccessColumn);
            this.radGridMenus.MasterTableView.Columns.Add(customerAccessColumn);
        }

Pavlina
Telerik team
 answered on 04 Feb 2013
1 answer
106 views
2 answers
85 views
Hi.
So I have the RadControls for ASP.NET AJAX.

I have a hierarchy data (think of it as multi level sub menus).
I want to display this in the UI but in a grid view (no client side rendering/filtering) of some kind.
At the same time, I want to add custom controls or column to represent the item value, such as a checkbox or editable textbox.
I also want to add a column where it would have the options for "Update"
When they press Update, I want to be able to get the entire row details which contains the changes made by the user

does RadControls have anything like this? Any samples of it?
Many thanks!
Ahmed Ilyas
Top achievements
Rank 1
 answered on 04 Feb 2013
3 answers
181 views
Hi,

    I'm seeing white empty space above the scrollbar on the radgrid (first_Image.png). I went through several theards on this issue and found a css solution to modify the .rgHeaderDiv

.RadGrid

 

.rgHeaderDiv

 

{

 

border: 0px solid !important;

 

 

width: 100% !important;

 

}



This works fine for me except one issue.
This solution has distorted the alignment of the header and Items columns (second_Image.png). I could not figure out how to resolve this issue. Please help me.

Thanks
Rajesh
Pavlina
Telerik team
 answered on 04 Feb 2013
3 answers
123 views
Hi Telerik team,

I've been living through the annoying auto generated code in RadGrid for like 2-3 years. Today I find that enough is enough, so now I gonna report this to you guys and see if there's any solution. Please see code below: 

<telerik:RadGrid ID="grdTest" runat="server" Skin="custom" EnableEmbeddedSkins="false" EnableTheming="false"
                                                AllowPaging="false" AllowSorting="false" BorderStyle="None" ShowHeader="true" Width="680px">
                                                <ClientSettings EnablePostBackOnRowClick="true" EnableRowHoverStyle="true">
                                                    <Selecting AllowRowSelect="true" />
                                                <Selecting AllowRowSelect="true" /><Selecting AllowRowSelect="true" /><Selecting AllowRowSelect="true" /><Selecting AllowRowSelect="true" /><Selecting AllowRowSelect="true" /><Selecting AllowRowSelect="true" />
<Selecting AllowRowSelect="true" /><Selecting AllowRowSelect="true" /><Selecting AllowRowSelect="true" />
<Selecting AllowRowSelect="true" /><Selecting AllowRowSelect="true" /><Selecting AllowRowSelect="true" />

</ClientSettings>

Please take note on the BOLD part, all this code will be auto generated whenever i save the aspx file and only happen if EnablePostBackOnRowClick="true". The code will double up for every save, meaning from 1 line of <Selecting AllowRowSelect="true" /> will become 2 lines, then 4 lines, then 8 lines, and eventually crash my VS2010. Then I'll have to edit the aspx file manually to remove all the duplicate lines in order to run my VS2010 again.

By the way, I'm using Telerik WebUI VSExtensions 2010.03.1109.0.
Angel Petrov
Telerik team
 answered on 04 Feb 2013
2 answers
122 views
We are trying to establish some test automation around the rad tree view and need a way to identify tree nodes client side. We would like to use the RadTreeNode.Value property to do this. We are setting this value server side.
eg     

RadTreeNode treeNode = new RadTreeNode();

treeNode.Value = itemID;  //eg 3636

But in the resulting html we can't find the itemID.

<li class="rtLI" _item="[object Object]" _itemTypeName="Telerik.Web.UI.RadTreeNode">
    <div class="rtTop" jQuery1357770307520="7">
    <span class="rtSp"/>
    <input class="rtChk" type="checkbox" value="on"/>
    <span class="rtIn EEMCheckBoxNode" jQuery1357770307520="8">
        Text - Air Heat Flow (BTU 59)

Any help would be appreciated.

Dave
Dave
Top achievements
Rank 1
 answered on 04 Feb 2013
7 answers
113 views
I am trying to localize my text in the pager of my RadGrid.

<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" PagerTextFormat="{0} {1} {2} {3} {5} records {4} " />

But what displays is "null records" with the controls to the right.

What might be causing this?
Josh
Top achievements
Rank 1
 answered on 04 Feb 2013
1 answer
184 views
hi
i've this code:

<telerik:AjaxSetting AjaxControlID="Categoria">
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1"
            LoadingPanelID="RadAjaxLoadingPanel1" />
    </UpdatedControls>
</telerik:AjaxSetting>

is possible to start loadingpanel only to code behind? load loadingpanel after checking if .. then in code behid the SelectedIndexChanged event of a radcombox?
Maria Ilieva
Telerik team
 answered on 04 Feb 2013
2 answers
125 views
Hi,

How to change the undock image of RadSlidingPane???


Regards
Shirish
Shirish
Top achievements
Rank 1
 answered on 04 Feb 2013
4 answers
214 views
So we have a RadGrid on one of our pages that has some GridBoundColumns and GridTemplateColumns. Over on the left of the screen we have some input that they can fill in and hit submit to do a basic search and bind the info to the grid. The grid renders correctly within the page the first time. However, once the first search is done, the first bound column width is extremely long, which "rams" the rest of the content off to the right and a horizontal scroll bar renders. There is no need for the horizontal scroll bar, the data should fit just fine, and the column should not be so wide!

The OnGridCreated event that is assigned only handles vertical dimensions and is not relevant to the issue.

Using binary version 2012.2.607.0

Page Markup:
<asp:Content ID="Content3" ContentPlaceHolderID="PageBody" runat="server">
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableHistory="True" OnAjaxRequest="AccountSearch">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="AccountSearchMultiPage" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="InquiryScriptBlock" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="InquiryPanelBar">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="AccountSearchMultiPage" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="InquiryScriptBlock" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="AccountSearchMultiPage">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="AccountSearchMultiPage" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="InquiryPanelBar" />
                    <telerik:AjaxUpdatedControl ControlID="InquiryScriptBlock" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server" />
     
    <div class="PageNest">
    <telerik:RadSplitter ID="InquiryPageSplitter" runat="server" Orientation="Vertical" Width="100%" Height="100%"
     OnClientLoaded="ResizeAccountSearchGrid" OnClientResized="ResizeAccountSearchGrid" CssClass="MainRadSplitter"
     ResizeWithBrowserWindow="true"  >
        <telerik:RadPane ID="RadPane1" runat="server" Width="200" Height="100%" Collapsed="false">
            <telerik:RadPanelBar ID="InquiryPanelBar" runat="server" CssClass="LeftColumnPanelBar" OnItemClick="ViewAccountDetails" OnClientItemClicking="InquiryPanelBarRedirect">
                <Items>
                    <telerik:RadPanelItem Text="Inquiry Options" PreventCollapse="true" Expanded="true" PostBack="false" Value="InquiryMain">
                        <Items>
                            <telerik:RadPanelItem ID="InquiryOptions" PostBack="false" Value="InquiryOptions" >
                                <ItemTemplate>
                                    <div style="margin-left: 10px">
                                        <telerik:RadTextBox ID="AccountNumberTextBox" runat="server" EmptyMessage="Account Number" />
                                        <telerik:RadTextBox ID="NameTextBox" runat="server" EmptyMessage="Name" />
                                        <telerik:RadMaskedTextBox ID="SSNTextBox" runat="server" EmptyMessage="SSN" HideOnBlur="True" />
                                        <telerik:RadMaskedTextBox ID="PhoneTextBox" runat="server" EmptyMessage="Telephone" HideOnBlur="True" />
                                        <telerik:RadComboBox ID="CustomComboBox" runat="server" EmptyMessage="Custom Search Field" OnClientSelectedIndexChanged="SetCustomTextBoxFocus" />
                                        <telerik:RadTextBox ID="CustomTextBox" runat="server" EmptyMessage="Choose an option above" />
                                        <telerik:RadButton ID="SearchButton" runat="server" Text="Submit" OnClick="AccountSearch" />
                                    </div>
                                </ItemTemplate>
                            </telerik:RadPanelItem>                           
                        </Items>
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem Text="Recently Viewed Accounts" PreventCollapse="true" Expanded="true" PostBack="false" Value="RecentlyViewedMain">
                        <Items>
                                 
                        </Items>
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem ID="OnlineActivityReports" Value="OnlineActivityReports" Text="Online Activity Reports" PreventCollapse="true" Expanded="true" PostBack="false">
                        <Items>
                            <telerik:RadPanelItem Text="Account Payments Reported" Value="PaymentHistory" PostBack="false" />
                            <telerik:RadPanelItem Text="Account Edit Requests" Value="EditHistory" PostBack="false" />
                            <telerik:RadPanelItem Text="Account Cancellation Requests" Value="CancelHistory" PostBack="false" />
                            <telerik:RadPanelItem Text="Populated at Page_Load" Value="PrecollectActions" PostBack="false" />
                        </Items>
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelBar>
        </telerik:RadPane>
        <telerik:RadSplitBar ID="RadSplitBar1" runat="server" CollapseMode="Forward" EnableResize="false" />
        <telerik:RadPane ID="RadPane2" runat="server" Height="100%" Scrolling="None">
 
                <telerik:RadMultiPage ID="AccountSearchMultiPage" runat="server" SelectedIndex="0" Height="100%" >
 
                    <telerik:RadPageView ID="AccountSearchPageView" runat="server" Height="100%" Width="100%">
                        <div class="PageViewHeader">
                            <asp:Label ID="InquiryLabel" runat="server" CssClass="GridLabel" />
                        </div>
                        <telerik:RadGrid ID="AccountSearchGrid" runat="server" AutoGenerateColumns="false" ShowFooter="true"
                         OnItemCommand="AccountSearchGrid_ItemCommand" ShowHeader="True">
                            <MasterTableView DataKeyNames="Id" ClientDataKeyNames="Id" TableLayout="Auto">
                                <ItemStyle Wrap="false" />
                                <Columns>
                                    <telerik:GridBoundColumn HeaderText="Agency ID" DataField="HostID" UniqueName="HostID" Aggregate="Count" FooterStyle-HorizontalAlign="Left" FooterAggregateFormatString="Showing {0} Matches" />
                                    <telerik:GridBoundColumn HeaderText="Account ID" DataField="ClientAccountID" UniqueName="ClientAccountID" />
                                    <telerik:GridTemplateColumn HeaderText="Name" UniqueName="Name">
                                        <ItemTemplate>
                                            <asp:LinkButton runat="server" CommandName="ShowDetail" CommandArgument='<%# Eval("ID") %>' Text="<%# DisplayAccountName() %>" />
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridButtonColumn HeaderText="Packet #" DataTextField="PacketNumber" UniqueName="PacketNumber" ButtonType="LinkButton" CommandName="ShowPacket" />
                                    <telerik:GridTemplateColumn HeaderText="Address" UniqueName="Address">
                                        <ItemTemplate>
                                            <%# FormatEval("Address1", "{0}<br/>") %>
                                            <%# FormatEval("Address2", "{0}<br/>") %>
                                            <%# FormatEval("City", "{0}, ")%>
                                            <%# FormatEval("State")%>
                                            <%# FormatEval("Zip") %>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn HeaderText="Date Assigned" DataField="DateAssigned" DataFormatString="{0:d}" UniqueName="DateAssigned" FooterStyle-HorizontalAlign="Left" Aggregate="Max" DataType="DateTime" FooterAggregateFormatString="Most Recent: {0:d}" />
                                    <telerik:GridNumericColumn HeaderText="Principal" DataField="AmountAssigned" DataFormatString="{0:C}" UniqueName="AmountAssigned" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" Aggregate="Sum" />
                                    <telerik:GridNumericColumn HeaderText="Balance" DataField="CurrBalance" DataFormatString="{0:C}" UniqueName="CurrBalance" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" Aggregate="Sum" />
                                </Columns>
                                <FooterStyle HorizontalAlign="Right" />
                            </MasterTableView>
                            <ClientSettings>
                                <Scrolling AllowScroll="true" UseStaticHeaders="true" Scrollheight="100%" />
                                <ClientEvents OnGridCreated="ResizeAccountSearchGrid" />
                            </ClientSettings>
                        </telerik:RadGrid>
                    </telerik:RadPageView>
 
                    <telerik:RadPageView ID="AccountDetailPageView" runat="server">
                        <caw:AccountDetail ID="AccountDetailControl" runat="server" OnAccountLoaded="UpdateRecentlyViewedList" />
                    </telerik:RadPageView>
 
                </telerik:RadMultiPage>
    
        </telerik:RadPane>
    </telerik:RadSplitter>
    </div>
    <telerik:RadScriptBlock ID="InquiryScriptBlock" runat="server">
        <script type="text/javascript">
            function InquiryPanelBarRedirect(sender, args) {
                var value = args.get_item().get_value();
                if (value == "PaymentHistory") {
                    <%= Navigator.OnlineActivity(OnlineActivityType.PaymentHistory, Configuration[Vars.PrecollectName]).ToEventScript() %>
                }
                if (value == "EditHistory") {
                    <%= Navigator.OnlineActivity(OnlineActivityType.EditHistory, Configuration[Vars.PrecollectName]).ToEventScript() %>
                }
                if (value == "CancelHistory") {
                    <%= Navigator.OnlineActivity(OnlineActivityType.CancelHistory, Configuration[Vars.PrecollectName]).ToEventScript() %>
                }
                if (value == "PrecollectActions") {
                    <%= Navigator.OnlineActivity(OnlineActivityType.PrecollectActions, Configuration[Vars.PrecollectName]).ToEventScript() %>
                }
            }
             
            function SetCustomTextBoxFocus(sender, args) {
                $('#<%= InquiryOptions.FindControl("CustomTextBox").ClientID %>').focus();
            }
 
            function ResizeAccountSearchGrid(sender, args) {
 
                ResizeGrid($find("<%= AccountSearchGrid.ClientID %>"));
            }
        </script>
    </telerik:RadScriptBlock>
</asp:Content>

protected void AccountSearch(object sender, EventArgs eventArgs)
{
    //reset the grid to the default list of columns - removing any extras added by the Custom search box
    var defaultColumns = new List<string> { "Name", "HostID", "ClientAccountID", "PacketNumber", "Address", "AmountAssigned", "CurrBalance", "DateAssigned", "ViewDetailsLink" };
    defaultColumns.AddRange(Configuration[Vars.InquirySearchSummaryAdditionalFields].ToString().Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries));
 
    var columnsToRemove = AccountSearchGrid.Columns.Cast<GridColumn>().Where(column => !defaultColumns.Contains(column.UniqueName)).ToList();
    foreach (var column in columnsToRemove)
        AccountSearchGrid.Columns.Remove(column);
 
    var searchParameters = new Dictionary<IList<AccountField>, string>();
    var inquiryBar = InquiryPanelBar.FindItemByValue("InquiryOptions");          
 
    //iterate all RadControls within the InquiryOptions panel bar item
    foreach (var control in inquiryBar.Controls)
    {
        //make sure the control is a RadInput
        var input = control as RadInputControl;
        if (input == null) continue;
 
        var id = input.ID;
        //if the control uniqueId starts with the word Custom, skip until later
        if (id.StartsWith("Custom")) continue;
        //verify the input has a value
        var value = input.Text.Trim();
        if (String.IsNullOrEmpty(value)) continue;
 
        //get the search group from the Id of the input.  eg. NameTextBox ID value equals InquiryNameSearchFields - a Configuration Variable from database
        var searchGroup = String.Format("Inquiry{0}SearchFields", id.Replace("TextBox", String.Empty));
        //the searchGroup is a comma space separated list of database column names to search with this input
        var fieldNames = Configuration[searchGroup].ToString().Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
        //get the AccountField objects from the field names, will automatically be trimmed by the client field permissions
        var fields = User.ParentCawClient.AccountFields.Where(field => fieldNames.Contains(field.ColumnName)).ToList();
 
        //if we are searching using a masked input we want to use the literals
        var radMaskedTextBox = control as RadMaskedTextBox;
        if (radMaskedTextBox != null) value = radMaskedTextBox.TextWithLiterals.Trim();
 
        //add the field list and the value to the search parameters
        searchParameters.Add(fields, value);
    }
    //check the custom search box
    var custom = ((RadTextBox)InquiryOptions.FindControl("CustomTextBox")).Text;
    var combo = (RadComboBox)InquiryOptions.FindControl("CustomComboBox");
    //using Text property here since the SelectedText and SelectedValue come back as empty strings for some reason
    var selected = combo.Text;
    if (!String.IsNullOrEmpty(custom) && !String.IsNullOrEmpty(selected))
    {
        var customField = User.ParentCawClient.AccountFields.Single(fld => fld.DisplayName == selected);
        searchParameters.Add(new List<AccountField> { customField }, custom);
        var column = new GridBoundColumn();
        AccountSearchGrid.Columns.Add(column);
        column.HeaderText = customField.DisplayName;
        column.DataField = customField.ColumnName;
        column.UniqueName = customField.ColumnName;
    }
 
    InquiryLabel.Text = @"Inquiry results";
 
    //send the dictionary to the account search for handling, bind the results to the searchgrid
    AccountSearchGrid.DataSource = _accountService.AccountInquiry(searchParameters);
    AccountSearchGrid.Rebind();
 
    InquiryPanelBar.ClearSelectedItems();
 
    //if only one result was found take the user directly to the detail screen.
    if (AccountSearchGrid.Items.Count == 1)
    {
 
        var row = AccountSearchGrid.Items[0];
        var id = int.Parse(row.GetDataKeyValue("Id").ToString());
        ViewAccountDetails(id, custom);
    }
    else
        AccountSearchMultiPage.SelectedIndex = AccountSearchPageView.Index;
}
Maria Ilieva
Telerik team
 answered on 04 Feb 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?