Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
157 views

I have the following version of your ASP.NET AJAX controls and experiencing a rather frustrating issue.  I would like to use horizontal scrolling and having six frozen columns because we have over 20 columns in our gird.. 

When I have the following settings below the grid does not expand 100% on each side.  It will only expand to fill in the whole area when I do one of two things.

 

  1. Grab a column header and expand it, even just a little movement makes the grid expand the whole distance.
  2. Scrolling horizontally also causes the columns to no longer align under the correct data.
  3. Another think, I have no issues when running on my pc with localhost.  The issue only arrises when I push the code to the server.
  4. This only happens in Internet Explorer 9 with Compatibility View disabled 

 

In order to avoid this unpleasant view I have had to turn UseStaticHeaders to false.

 

There has got to be another way, I want the headers to be static.

 

We are currently using Telerik version 2013.1.220.35 


Here are the client settings we are using

<ClientSettings AllowDragToGroup="True" ClientEvents-OnRowSelecting="CancelNonInputSelect"  ClientEvents-OnRowDeselecting="CancelNonInputSelect">
<Resizing AllowColumnResize="True" AllowRowResize="False" ResizeGridOnColumnResize="False"  ClipCellContentOnResize="True" EnableRealTimeResize="False" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" FrozenColumnsCount="6" />
<Selecting AllowRowSelect="True" />
</ClientSettings>

Your help would be much appreciated.

Milena
Telerik team
 answered on 22 Mar 2013
1 answer
177 views
I am using an example provided in this post http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-use-gridtemplatecolumn-in-radgrid-for-google-like-filtering.aspx which was attached as a zip file called "templatecolumnwithfiltering2.zip". I've re-created it using our SQL Server table data, however, I added some more columns and what I am getting is concatenated data of all the columns in each column. I have added a screenshot of what I am getting. Each column should only hold one type of data. The columns should be "Client Name", "Billing Name" and "Client Number", respectively, but each column has all the data jumbled up in each column instead of in separate columns.
Here is my code:
<asp:ScriptManager ID="scriptManager" runat="server">
        </asp:ScriptManager>
        <asp:PlaceHolder ID="holder" Visible="true" runat="server"></asp:PlaceHolder>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT * FROM [table]"></asp:SqlDataSource>
        <telerik:RadAjaxPanel ID="ajaxPanel" EnableAJAX="false" runat="server">
 
        </telerik:RadAjaxPanel>


protected void Page_Init(object sender, EventArgs e)
       {
           RadGrid grid = new RadGrid();
 
           grid.ID = "RadGrid1";
           grid.MasterTableView.DataSourceID = "SqlDataSource1";
           grid.MasterTableView.DataKeyNames = new string[] { "Record_ID" };
           grid.Skin = "Default";
           grid.PageSize = 10;
           grid.AllowPaging = true;
           grid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
           grid.AutoGenerateColumns = false;
           grid.AllowFilteringByColumn = true;
 
 
 
           GridBoundColumn boundColumn = new GridBoundColumn();
           grid.MasterTableView.Columns.Add(boundColumn);
           boundColumn.DataField = "Record_ID";
           boundColumn.HeaderText = "Record_ID ID";
           boundColumn.UniqueName = "Record_ID";
 
 
           NewTemplateColumn templateColumn = new NewTemplateColumn();
           templateColumn.ItemTemplate = new TemplateColumn();
           grid.MasterTableView.Columns.Add(templateColumn);
           templateColumn.DataField = "Client_Name";
           templateColumn.HeaderText = "Client Name";
           templateColumn.UniqueName = "Client_Name";
 
           NewTemplateColumn templateColumn1 = new NewTemplateColumn();
           templateColumn1.ItemTemplate = new TemplateColumn();
           grid.MasterTableView.Columns.Add(templateColumn1);
           templateColumn1.DataField = "Billing_Atty";
           templateColumn1.HeaderText = "Billing Attorney";
           templateColumn1.UniqueName = "Billing_Atty";
 
           NewTemplateColumn templateColumn2 = new NewTemplateColumn();
           templateColumn2.ItemTemplate = new TemplateColumn();
           grid.MasterTableView.Columns.Add(templateColumn2);
           templateColumn2.DataField = "Client_Number";
           templateColumn2.HeaderText = "Client Number";
           templateColumn2.UniqueName = "Client_Number";
 
           ajaxPanel.Controls.Add(grid);
 
           grid.DataBind();
 
       }
 
 
 
   }
 
   public partial class NewTemplateColumn : GridTemplateColumn
   {
       private SqlDataSource comboDataSource = new SqlDataSource(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(), "select Client_Name FROM Matter_Subs");
       //RadGrid will call this method when it initializes the controls inside the filtering item cells
       protected override void SetupFilterControls(TableCell cell)
       {
           base.SetupFilterControls(cell);
           cell.Controls.RemoveAt(0);
           RadComboBox combo = new RadComboBox();
           combo.ID = ("RadComboBox1" + this.UniqueName);
           combo.ShowToggleImage = false;
           //combo.Skin = "Office2007";
           combo.EnableLoadOnDemand = true;
           combo.AutoPostBack = true;
           combo.MarkFirstMatch = true;
           combo.Height = Unit.Pixel(100);
           combo.ItemsRequested += this.list_ItemsRequested;
           combo.SelectedIndexChanged += this.list_SelectedIndexChanged;
           cell.Controls.AddAt(0, combo);
           cell.Controls.RemoveAt(1);
           RadComboBox combo1 = new RadComboBox();
           combo1.ID = ("RadComboBox2" + this.UniqueName);
           combo1.ShowToggleImage = false;
           //combo.Skin = "Office2007";
           combo1.EnableLoadOnDemand = true;
           combo1.AutoPostBack = true;
           combo1.MarkFirstMatch = true;
           combo1.Height = Unit.Pixel(100);
           combo1.ItemsRequested += this.list1_ItemsRequested;
           combo1.SelectedIndexChanged += this.list1_SelectedIndexChanged;
           cell.Controls.AddAt(0, combo1);
           cell.Controls.RemoveAt(1);
           RadComboBox combo2 = new RadComboBox();
           combo2.ID = ("RadComboBox3" + this.UniqueName);
           combo2.ShowToggleImage = false;
           //combo.Skin = "Office2007";
           combo2.EnableLoadOnDemand = true;
           combo2.AutoPostBack = true;
           combo2.MarkFirstMatch = true;
           combo2.Height = Unit.Pixel(100);
           combo2.ItemsRequested += this.list2_ItemsRequested;
           combo2.SelectedIndexChanged += this.list1_SelectedIndexChanged;
           cell.Controls.AddAt(0, combo2);
           cell.Controls.RemoveAt(1);
       }
 
       //RadGrid will cal this method when the value should be set to the filtering input control(s)
       protected override void SetCurrentFilterValueToControl(TableCell cell)
       {
           base.SetCurrentFilterValueToControl(cell);
           RadComboBox combo = (RadComboBox)cell.Controls[0];
           if ((this.CurrentFilterValue != string.Empty))
           {
               combo.Text = this.CurrentFilterValue;
           }
           RadComboBox combo1 = (RadComboBox)cell.Controls[0];
           if ((this.CurrentFilterValue != string.Empty))
           {
               combo1.Text = this.CurrentFilterValue;
           }
           RadComboBox combo2 = (RadComboBox)cell.Controls[0];
           if ((this.CurrentFilterValue != string.Empty))
           {
               combo2.Text = this.CurrentFilterValue;
           }
       }
 
       //RadGrid will cal this method when the filtering value should be extracted from the filtering input control(s)
       protected override string GetCurrentFilterValueFromControl(TableCell cell)
       {
           RadComboBox combo = (RadComboBox)cell.Controls[0];
           return combo.Text;
       }
       private void list_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
       {
           ((RadComboBox)o).DataValueField = "Client_Name";
           ((RadComboBox)o).DataTextField = "Client_Name";
           comboDataSource.SelectCommand = "SELECT DISTINCT Client_Name FROM table WHERE Client_Name LIKE '" + e.Text + "%'";
           ((RadComboBox)o).DataSource = comboDataSource.Select(new DataSourceSelectArguments());
           ((RadComboBox)o).DataBind();
       }
 
       private void list_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
       {
           GridFilteringItem filterItem = (GridFilteringItem)((RadComboBox)o).NamingContainer;
           if ((this.UniqueName == "Client_Name"))
           {
               //this is filtering for integer column type
               filterItem.FireCommandEvent("Filter", new Pair("EqualTo", this.UniqueName));
           }
           //filtering for string column type
           filterItem.FireCommandEvent("Filter", new Pair("Contains", this.UniqueName));
       }
 
       private void list1_ItemsRequested(object o1, RadComboBoxItemsRequestedEventArgs e1)
       {
           ((RadComboBox)o1).DataValueField = "Billing_Atty";
           ((RadComboBox)o1).DataTextField = "Billing_Atty";
           comboDataSource.SelectCommand = "SELECT DISTINCT Billing_Atty FROM table WHERE Billing_Atty LIKE '" + e1.Text + "%'";
           ((RadComboBox)o1).DataSource = comboDataSource.Select(new DataSourceSelectArguments());
           ((RadComboBox)o1).DataBind();
       }
 
       private void list1_SelectedIndexChanged(object o1, RadComboBoxSelectedIndexChangedEventArgs e1)
       {
           GridFilteringItem filterItem = (GridFilteringItem)((RadComboBox)o1).NamingContainer;
           if ((this.UniqueName == "Billing_Atty"))
           {
               //this is filtering for integer column type
               filterItem.FireCommandEvent("Filter", new Pair("EqualTo", this.UniqueName));
           }
           //filtering for string column type
           filterItem.FireCommandEvent("Filter", new Pair("Contains", this.UniqueName));
       }
 
       private void list2_ItemsRequested(object o2, RadComboBoxItemsRequestedEventArgs e2)
       {
           ((RadComboBox)o2).DataValueField = "Client_Number";
           ((RadComboBox)o2).DataTextField = "Client_Number";
           comboDataSource.SelectCommand = "SELECT DISTINCT Client_Number FROM table WHERE Client_Number LIKE '" + e2.Text + "%'";
           ((RadComboBox)o2).DataSource = comboDataSource.Select(new DataSourceSelectArguments());
           ((RadComboBox)o2).DataBind();
       }
 
       private void list2_SelectedIndexChanged(object o2, RadComboBoxSelectedIndexChangedEventArgs e2)
       {
           GridFilteringItem filterItem = (GridFilteringItem)((RadComboBox)o2).NamingContainer;
           if ((this.UniqueName == "Client_Number"))
           {
               //this is filtering for integer column type
               filterItem.FireCommandEvent("Filter", new Pair("EqualTo", this.UniqueName));
           }
           //filtering for string column type
           filterItem.FireCommandEvent("Filter", new Pair("Contains", this.UniqueName));
       }
 
   }
 
   public partial class TemplateColumn : ITemplate
   {
 
       public void InstantiateIn(Control container)
       {
 
           LiteralControl literalControl = new LiteralControl();
           literalControl.ID = "literalControl";
           literalControl.DataBinding += new EventHandler(literalControl_DataBinding);
 
           LiteralControl literalControl1 = new LiteralControl();
           literalControl1.ID = "literalControl1";
           literalControl1.DataBinding += new EventHandler(literalControl1_DataBinding);
 
           LiteralControl literalControl2 = new LiteralControl();
           literalControl2.ID = "literalControl2";
           literalControl2.DataBinding += new EventHandler(literalControl2_DataBinding);
 
           CheckBox box = new CheckBox();
 
           box.ID = "boxControl";
 
           box.DataBinding += new EventHandler(box_DataBinding);
 
           container.Controls.Add(literalControl);
           container.Controls.Add(literalControl1);
           container.Controls.Add(literalControl2);
           container.Controls.Add(box);
 
       }
 
       void box_DataBinding(object sender, EventArgs e)
       {
           CheckBox box = (CheckBox)sender;
 
           GridDataItem container = box.NamingContainer as GridDataItem;
 
           if (container != null)
               box.Checked = (bool)((DataRowView)container.DataItem)["Flag"];
           else
           {
               GridEditFormItem editFormContainer = box.NamingContainer as GridEditFormItem;
               box.Enabled = (bool)((DataRowView)editFormContainer.DataItem)["Flag"];
 
           }
       }
 
       protected void literalControl_DataBinding(object sender, EventArgs e)
       {
           LiteralControl l = (LiteralControl)sender;
 
           GridDataItem container = l.NamingContainer as GridDataItem;
 
           if (container != null)
           {
               l.Text = ((DataRowView)container.DataItem)["Client_Name"].ToString();
 
           }
           else
           {
               GridEditFormItem editFormContainer = l.NamingContainer as GridEditFormItem;
               l.Text = ((DataRowView)editFormContainer.DataItem)["Client_Name"].ToString();
           }
       }
 
       protected void literalControl1_DataBinding(object sender, EventArgs e)
       {
           LiteralControl lc1 = (LiteralControl)sender;
 
           GridDataItem container1 = lc1.NamingContainer as GridDataItem;
 
           if (container1 != null)
           {
               lc1.Text = ((DataRowView)container1.DataItem)["Billing_Atty"].ToString();
 
           }
           else
           {
               GridEditFormItem editFormContainer = lc1.NamingContainer as GridEditFormItem;
               lc1.Text = ((DataRowView)editFormContainer.DataItem)["Billing_Atty"].ToString();
           }
       }
 
       protected void literalControl2_DataBinding(object sender, EventArgs e)
       {
           LiteralControl lc2 = (LiteralControl)sender;
 
           GridDataItem container2 = lc2.NamingContainer as GridDataItem;
 
           if (container2 != null)
           {
               lc2.Text = ((DataRowView)container2.DataItem)["Client_Number"].ToString();
 
           }
           else
           {
               GridEditFormItem editFormContainer = lc2.NamingContainer as GridEditFormItem;
               lc2.Text = ((DataRowView)editFormContainer.DataItem)["Client_Number"].ToString();
           }
       }


Radoslav
Telerik team
 answered on 22 Mar 2013
1 answer
79 views

Yesterday I was doing something and found this unexpected behavior with the Telerik controls as soon as override the page render. I see the grids sorting and telerik ajax not working when I have coded the following code.
I would really appreciate if any one has clue why this is happening for the following code snippet.

  protected override void Render(HtmlTextWriter writer)
{
    // setup a TextWriter to capture the markup
    TextWriter tw = new StringWriter();
    HtmlTextWriter htw = new HtmlTextWriter(tw);
    // render the markup into our surrogate TextWriter
    base.Render(htw);
    // get the captured markup as a string
    string pageSource = tw.ToString();
    MatchCollection matches = Regex.Matches(pageSource, @"\[\!\[(.*?)\]\!\]");
    List<string> finishedCaptures = new List<string>();
    // Use foreach loop.
    foreach (Match match in matches)
    {
        foreach (Capture capture in match.Captures)
        {
            if (!finishedCaptures.Contains(capture.Value))
            {
                pageSource = pageSource.Replace(capture.Value, ConfigFactory.Instance[capture.Value.Trim(new char[] { '[', ']', '!' })]);
                finishedCaptures.Add(capture.Value);
            }
        }
    }
    writer.Write(pageSource);
}
-Thanks for your precious time.
Slav
Telerik team
 answered on 22 Mar 2013
1 answer
244 views
my page (productionEntry.aspx) has a radGrid which contains a radAjaxManager whose settings allow for asynchronous postbacks of the radGrid:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGridProductionOrders">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGridProductionOrders" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

so RadGridProduictionOrders asynchronously posts back, which is fine.
now, however, the radGrid's editForm is a popup user control, and what i'd like to accomplish is to asynchronously postback some of the user control's content.
i have tried doing this with a radAjaxManagerProxy and a radAjaxPanel together and with each by itself inside the user control. each time the page asynchronously posts back according to the settings in the radAjaxManager from the productionEntry.aspx page.
this was the markup for the radAjaxManagerProxy in the user control. the content that i wanted to post back was inside Panel1:
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="Panel1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="Panel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>


how do i need to setup the page and/or user control to accomplish what i need?


Alex
Top achievements
Rank 2
 answered on 22 Mar 2013
1 answer
93 views
Please ignore this post.  Just found the answer.

http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrad-how-to-populate-dropdown-with-selection-from-another-dropdown-in-editform.aspx

Apologies to one and all (and I clearly need to find some more coffee...)

I have a RadGrid that edits records using the FormTemplate method.  So far, so good. 

Now I've been told that I have to add a dropdown and that SelectedIndexChange event must update two other controls in the editing FormTemplate (only those two controls).  This is intended to be the same as the setup in another screen that's already working, although not within a RadGrid.

What I've done so far is put that dropdown and the other two controls, RadComboBoxes, in a RadAjaxPanel within the FormTemplate.
(My Ajax experience so far is limited to putting controls within a RadAjaxPanel so they don't affect the rest of the page.)

The SelectedIndexChange fires but at this point I have no idea how to access the other dropdowns in order to refresh them.

Suggestions?
Milena
Telerik team
 answered on 22 Mar 2013
3 answers
63 views
I've read dozens of postings on the issues of why Vertical Gridlines are not appearing when I set: GridLines="Both"

But nothing works.  The property does work properly in Microsoft's GridView control but not in RadGrid.

I do not use any skins with RadGrid.

How do I get GridLines to appear?

Robert
Galin
Telerik team
 answered on 22 Mar 2013
4 answers
142 views
We have a grid with quite a few columns that we want to fit into a 1024x768 screen.

The grid is inside an html table cell (for certain reasons we have to do it using html tables).  The table has 4 columns, and the grid is in the second column with a colspan of 3
<tr>
<td>
</td>
<td colspan="3" style="max-width:895px;">
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" CellSpacing="0"
GridLines="Vertical" Height="285">
<ClientSettings>
<Scrolling AllowScroll="true" UseStaticHeaders="true"/>
</ClientSettings>
stuff ommitted for readability
</td>
</tr>

The problem now is, the grid goes extra long (as in wide).

As seen in the attached images, when a fixed width is specified for the grid (width=895px;) then the grid width fits, but there is a horizontal scroll bar that we don't want.

When there is no fixed width specified for the grid, then the grid goes past the width of the table/cell/etc, requiring the user to horizontally scroll on the browser window.

Screenshots were taken using IE9.

I also note that when we remove the Client Settings Scrolling AllowScroll, then it fits fine without a width specified for the grid.  But obviously it would not show a specific height for the grid.  Basically we want the grid to have a specific height regardless of how many rows of data it has (0, 1, 2, 400, etc).

Is there a way to get this to work?
Pavlina
Telerik team
 answered on 22 Mar 2013
10 answers
489 views
I am using "ServerSide" expand mode and using the following code to scroll to the last expanded node, but it is not working: 

        function ScrollToSelectedNode()
        {
                var tree = $find("<%= RadTreeView1.ClientID %>");
                //this was not working. so i used a hidden control to store the value of the last node clicked.
                //var selectedNode = treeviewInstance.SelectedNode;
                //The value of the expandedNode is set in the RadTreeView1_NodeExpand event on the server side
               var selectedNode = tree.findNodeByValue(document.getElementById("expandedNode").value);
               if (selectedNode != null)
               {
                selectedNode.select();
                selectedNode.scrollIntoView();
                //window.setTimeout(function() { selectedNode.scrollIntoView(); }, 200);
                }
        }


I will appreciate if you please help me out here.
Nicolaï
Top achievements
Rank 2
 answered on 22 Mar 2013
1 answer
82 views
Hi,

how can I get the specified item of a RadListBox using the index?

Thanks
Princy
Top achievements
Rank 2
 answered on 22 Mar 2013
13 answers
507 views
Hello, I am having trouble with a detail table in my hierarchical radgrid not updating to show the appropriate columns. I do have an AjaxManager on the page, but I am changing the datasource through a button click event not monitored by the AjaxManager. The colums are autogenerated, and on the columncreated method, HTMLEncode is set to true for GridBoundColumns. I looked into rebinding, needdatasource, and altering the viewstate with no luck.

The datasource I am using can be switched from a detailed to a summary view, so that columns that used to be in the radgrid should be removed on databind. Currently, the columns remain and are empty. I would guess that they are assigned null values.

ASPX
<telerik:RadGrid ID="rdgGridView" runat="server" AllowSorting="true" DataSourceID="datasource1" AutoGenerateColumns="false" AllowPaging="true" EnableViewState="true">
<MasterTableView DataSourceID="datasource1" DataKeyNames="ID" AutoGenerateColumns="false">
<DetailTables>
<telerik:GridTableView Name="Detail" runat="server" AutoGenerateColumns="true" AllowSorting="true">
<columns>
<telerik:GridTemplateColumn>
<HeaderTemplate>Link</HeaderTemplate>
<ItemTemplate><asp:LinkButton ID="LB" runat="server" Text="text" /></ItemTemplate>
</telerik:GridTemplateColumn>
</columns>
</DetailTables>
</MasterTableView>
</telerik:RadGrid>

VB
Private Sub Submit_Click(ByVal sender As System.object, ByVal e As System.EventArgs) Handles Submit.Click
 
rdgGridView.MasterTableView.DetailTables(0).DataSource = Nothing
 
rdgGridView.DataBind()
 
End Sub
 
  
 
Private Sub rdgGridView_DetailTableDataBind(ByVal sender As System.object, ByVal e As GridDetailTableDataBindEventArgs) Handles rdgGridView. GridDetailTableDataBindEventArgs
 
'Modify datasource
 
rdgGridView.MasterTableView.DetailTables(0).DataSource = DataSource
 
End Sub

So any thoughts would be appreciated.
Andrey
Telerik team
 answered on 22 Mar 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?