Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
152 views

Hi there,

Please help me.

I've tried the solution from a previous post(which is this):
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
    if (e.Item is  GridPagerItem)
        {
            GridPagerItem pager = (GridPagerItem)e.Item;
            RadComboBox PageSizeComboBox = (RadComboBox)pager.FindControl("PageSizeComboBox");
            RadComboBoxItem ComboItem = new RadComboBoxItem("All");
            PageSizeComboBox.Items.Insert(0, ComboItem);
            PageSizeComboBox.AutoPostBack = true;
            PageSizeComboBox.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(PageSizeComboBox_SelectedIndexChanged);
        }
    }
void PageSizeComboBox_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
   {
       //Handle the event
   }

The only problem i'm having is the line below. It keeps returning null:
PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;

This is my code behind:

public partial class Admin : System.Web.UI.Page
  {
    FXGrid FXGrid1 = new FXGrid();
    protected void Page_Init(object sender, EventArgs e)
    {
      FXGrid1.DataBind();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
      System.Web.HttpBrowserCapabilities browser = Request.Browser;
      TextBox txt = (TextBox)toolbarMenu.FindControl("txtSearch");
     
 DataTable dt = new DataTable();
 dt.Columns.Add("Date");
      dt.Columns.Add("MessageNo");
      dt.Columns.Add("From");
      dt.Columns.Add("NoofPages");
      dt.Columns.Add("TrackingNo");
      dt.Columns.Add("Status");
      dt.Columns.Add("CallerID");

      DataRow messagesRow = dt.NewRow();
      messagesRow["Date"] = "ALFKI";
      messagesRow["MessageNo"] = "Alfreds Futterkiste";
      messagesRow["From"] = "Alfreds Futterkiste";
      messagesRow["NoofPages"] = "Alfreds Futterkiste";
      messagesRow["TrackingNo"] = "Alfreds Futterkiste";
      messagesRow["Status"] = "Alfreds Futterkiste";
      messagesRow["CallerID"] = "Alfreds Futterkiste";
      dt.Rows.Add(messagesRow);

      DataRow messagesRow2 = dt.NewRow();
      messagesRow2["Date"] = "ALFKI";
      messagesRow2["MessageNo"] = "Alfreds Futterkiste";
      messagesRow2["From"] = "Alfreds Futterkiste";
      messagesRow2["NoofPages"] = "Alfreds Futterkiste";
      messagesRow2["TrackingNo"] = "Alfreds Futterkiste";
      messagesRow2["Status"] = "Alfreds Futterkiste";
      messagesRow2["CallerID"] = "Alfreds Futterkiste";
      dt.Rows.Add(messagesRow2);
      dt.Columns.Add("<img id='edit' style='border:0px;cursor:pointer' src='../../Images/Outlook/Edit.gif'>").SetOrdinal(0);

      DataRow[] chkEdit = new DataRow[dt.Rows.Count];
      for (int row = 0; row < dt.Rows.Count; row++)
      {
        chkEdit[row] = dt.Rows[row];
        chkEdit[row]["<img id='edit' style='border:0px;cursor:pointer' src='../../Images/Outlook/Edit.gif'>"] = "<img style='cursor:pointer' src='../../Images/Outlook/Edit.gif' value='" + dt.Rows[row][1] + "' onclick='showWin(" + dt.Rows[row][1] + ", "+row+")'>";
      }
    
      GridClientSelectColumn gcsc = new GridClientSelectColumn();
      gcsc.Resizable = false;
      FXGrid1.rowCount = dt.Rows.Count;

      FXGrid1.MasterTableView.Width = Unit.Percentage(100);
      FXGrid1.MasterTableView.TableLayout = GridTableLayout.Fixed;

      /*RadGrid's common attributes*/
      FXGrid1.GridLines = GridLines.None;
      FXGrid1.ID = "RG1";
      FXGrid1.AllowPaging = true;
      FXGrid1.AllowSorting = true;
      FXGrid1.BorderWidth = Unit.Pixel(0);

      FXGrid1.PagerStyle.AlwaysVisible = true;
      FXGrid1.MasterTableView.TableLayout = GridTableLayout.Fixed;
     

      FXGrid1.ClientSettings.Scrolling.AllowScroll = true;
      FXGrid1.ClientSettings.Scrolling.UseStaticHeaders = true;
      FXGrid1.ClientSettings.ClientEvents.OnGridCreated = "getFwdAddr";
      ttlRow.Value = FXGrid1.rowCount.ToString();
      FXGrid1.AllowMultiRowSelection = true;
      FXGrid1.ClientSettings.Selecting.AllowRowSelect = true;

      FXGrid1.pgName = "inbound";
      this.phIBRoute.Controls.Add(FXGrid1);
      FXGrid1.DataSource = dt;

      if (!IsPostBack)
      {
        FXGrid1.MasterTableView.Columns.Add(gcsc);
        FXGrid1.DataBind();
      }
      FXGrid1.setSize();
      Page.PreRender += new EventHandler(FXGrid1.setCombo);
    }
  }

This is my cs file:

public class FXGrid : RadGrid
    {       
        private int pgVal;
        private RadComboBox pgSize;      
        public int rowCount;      
        public double percentWidth = 0;
        public bool blackList = false;
        public String pgName = "";
        public String hideCol = "";
        public String setName;
        public String setNameVal;
        public DataTable dt;
        public String browserType;
        protected RadComboBox rcb = new RadComboBox();
        public FXGrid()
        {
            rcb.DataTextField = "Text";
            rcb.DataValueField = "Value";
            rcb.LoadContentFile(@"~\Common\Xml\GridPageSize.xml");
            pgVal = int.Parse(rcb.Items[rcb.SelectedIndex].Text);
            this.ClientSettings.Resizing.AllowColumnResize = true;
            this.ItemCreated += new GridItemEventHandler(this.testo);
           
            this.ItemDataBound +=new GridItemEventHandler(setCellTooltip);
            this.EnableViewState = true;
            this.ShowHeader = true;
            this.ClientSettings.Resizing.ClipCellContentOnResize = false;
            this.ClientSettings.Resizing.ResizeGridOnColumnResize = false;
            this.ClientSettings.Resizing.AllowResizeToFit = false;
            this.ViewStateMode = ViewStateMode.Enabled;

        }
         public void setCellTooltip(object sender, GridItemEventArgs e)
        {          
            int count = 0;
            if (e.Item is GridDataItem)
            {

                foreach (TableCell cell in e.Item.Cells)
                {

                    if (pgName == "docStore" || pgName == "netSetFaxAgentDR")
                    {
                        if (count >= 5)
                        {
                            String tmpStr = cell.Text.Replace("<nobr>", "");
                            cell.ToolTip = tmpStr.Replace("</nobr>", "");
                        }
                    }
                    else if (pgName == "utilitySearchMsg")
                    {
                        if (count >= 3)
                        {
                            String tmpStr = cell.Text.Replace("<nobr>", "");
                            cell.ToolTip = tmpStr.Replace("</nobr>", "");
                        }
                    }
                    else
                    {
                        if (count >= 4)
                        {
                            String tmpStr = cell.Text.Replace("<nobr>", "");
                            cell.ToolTip = tmpStr.Replace("</nobr>", "");
                        }
                    }
                    count++;
                }
            }
        }
        public void testo(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridPagerItem)
            {
                pgSize = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
                pgSize.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(setSize);
                pgSize.Items.Clear();
                for (int sub = 0; sub < rcb.Items.Count; sub++) {
                    pgSize.Items.Add(new RadComboBoxItem(rcb.Items[sub].Text));
                    pgSize.FindItemByText(rcb.Items[sub].Text).Attributes.Add("ownerTableViewId", this.MasterTableView.ClientID);
                }
            }
        }
        public void setSize()//This is called at the last line in my code behind.
        {
            this.PageSize = pgVal;
            this.MasterTableView.Rebind();
        }

If i remove this line, PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true; i can see that the pagesizecombo is showing the correct value but when i click on it, page reloads but the size of rows is not changed. Another problem is when i click on other value, the page reloads and the pagesizecombo selects the default value.

Please help. I've looked for a lot of articles but none seems to fit me.

Regards,
Dexter

Princy
Top achievements
Rank 2
 answered on 23 Sep 2011
1 answer
199 views
Hi,

We have a grid with a GridDropDownColumn, the values for this column are shown as non-breakign space '&nbsp;' when the data is an empty string. This is our column in the grid:
<telerik:GridDropDownColumn FilterControlWidth="250px" DataField="country_id" DataSourceID="sds_countries"
    HeaderText="Country" ListTextField="name" ListValueField="country_id" UniqueName="country_id">
    <FilterTemplate>
        <telerik:RadComboBox ID="ddl_countries" DataSourceID="sds_countries" DataTextField="name"
            DataValueField="country_id" AppendDataBoundItems="true" SelectedValue='<%#  ((GridItem)Container).OwnerTableView.GetColumn("country_id").CurrentFilterValue %>'
            runat="server" OnClientSelectedIndexChanged="CountryChanged">
            <Items>
                <telerik:RadComboBoxItem Text="All" />
            </Items>
        </telerik:RadComboBox>
        <telerik:RadScriptBlock ID="rsb_countries" runat="server">
            <script type="text/javascript">
                function CountryChanged(sender, args) {
                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                    tableView.filter("country_id", args.get_item().get_value(), "EqualTo");
                }
            </script>
        </telerik:RadScriptBlock>
    </FilterTemplate>
    <HeaderStyle Width="180px" />
</telerik:GridDropDownColumn>

I have tried to use the following code on the on item data bound event:
if (e.Item is GridDataItem)
        {
            foreach (TableCell cell in e.Item.Cells)
            {
                cell
                if (cell.Text == " ")
                    cell.Text = "";
            }
        }
   
However our edit column is being overwritten with an empty string. Any help would be appreciated.
Iana Tsolova
Telerik team
 answered on 23 Sep 2011
1 answer
100 views
I have a TreeList control with a page size of 10 which will have multiple pages of data...and I want to make an item on the second page (a) selected and (b) expanded, AND (c) navigate to that item so that we're on second page of data.  I don't see a way to accomplish (c) in server-side code.  Is it possible, or is there a client-side trick that works?
Johny
Top achievements
Rank 1
 answered on 23 Sep 2011
1 answer
209 views
Hi All,

I tried last four hours to implement check and uncheck all nodes in telerik tree view using javascript. but i was not able to achieve.
can any body post the code?

Thanks and regards
Vetrivelmp.
Shinu
Top achievements
Rank 2
 answered on 23 Sep 2011
1 answer
123 views
Hi! I have a problem. I want to localize RadWindow. I use Window with  page .aspx. And I do not know how to locate the controls that are located within these's page.
Shinu
Top achievements
Rank 2
 answered on 23 Sep 2011
9 answers
767 views
I think a nice feature of the RadNumericTextbox would be to have an additional property for removing trailing zeros.

Currently,

If DecimalDigits=4, lets say

User Enters : 1.2, control looses focus and 1.2000 is displayed. Would prefer to see: 1.2 (Ironically, when control has focus trailing zero are removed).

I can think of a couple ways to accomplish this feature.

1) Add a new property RemoveTrailingZeros to the Formatting object. If true then remove trailing zeros.

2) Even better, would be to enhance format strings (Positive and Negative) and for each different style (Focused, ReadOnly, Enabled etc...)  This would provide more flexibility and allow the developer to improve the user experience by having much better control over formatting.

For example, PositivePattern="0.0000" (display trailing zeros) PositivePattern = "0.####" (remove trailing zeros).

I have worked around the issue via some script, but would prefer the control to handle this by default or via format strings.

Thanks for considering this feature request,
Mark.


Steve Napurano
Top achievements
Rank 1
 answered on 23 Sep 2011
2 answers
193 views
Hello,

i have two datatables and i need to draw line chart dynamically (Codebehind) with those data.
2 seires line chart i want.

below is my datatable data.

1st Datatable having data as below
Q1 08 150453000
Q2 08 158688000
Q4 08 1515
Q1 09 1000

2nd Datatable having data as below .
Q4 08 2525
Q1 09 2000

above are 2 series data . Please help me how to draw 2 series line chart for above data .
Mugdha Aditya
Top achievements
Rank 1
 answered on 23 Sep 2011
1 answer
266 views
Hi,

I'm looking for the setting to add an underline on my column headings. I've tried all that I can find and nothing seems to work. the following is a sample for one of my column.

 

 

<telerik:GridTemplateColumn UniqueName="AreaName" HeaderText="Area"  

SortExpression="_AreaName" ItemStyle-Width="150px" DataField="_AreaName"  

AndCurrentFilterFunction="Contains" FilterControlWidth="125px">  

 

<FooterTemplate>  

Template footer 

</FooterTemplate>  

 

<FooterStyle VerticalAlign="Middle" HorizontalAlign="Center" />  

 

<ItemTemplate> 

<%

#DataBinder.Eval(Container.DataItem, "_AreaName")%>  

</ItemTemplate>  

 

<EditItemTemplate>  

 

<telerik:RadComboBox runat="server" ID="RadComboBoxArea"  

OnItemsRequested="RadComboBoxArea_ItemsRequested"  

 

EnableLoadOnDemand="True" DataTextField="AreaName"  

 

DataValueField="ID" AutoPostBack="true"  

 

HighlightTemplatedItems="true" Height="140px" Width="175px" DropDownWidth="200px"  

 

OnSelectedIndexChanged="ComboBox1_OnSelectedIndexChangedHandler" 

onclientdropdownopening="OnClientDropDownOpening">  

<ItemTemplate> 

<%# DataBinder.Eval(Container, "Text")%>  

</ItemTemplate>  

 

</telerik:RadComboBox>  

 

</EditItemTemplate>  

 

<HeaderStyle Width="150px" HorizontalAlign="Center" VerticalAlign="Bottom"  

Font-Underline="True" />  

 

<ItemStyle Width="150px" HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>  

 

</telerik:GridTemplateColumn>

thanks,

Minh bui 

Shinu
Top achievements
Rank 2
 answered on 23 Sep 2011
2 answers
234 views
How can I make it so the fields I have set as read only display on the edit form (popup)? The way it is now they are invisible, I'd like them to still be displayed on the form but read only, or disabled.

Thanks
Shinu
Top achievements
Rank 2
 answered on 23 Sep 2011
0 answers
128 views
hi,
 I need to display submenu in the same starting position of the parent menu. I can achive this using offsetX. But can anyone help to achive this using javascript. So that it till dynamically set the left side its parent
Akhil Raj
Top achievements
Rank 1
 asked on 23 Sep 2011
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?