In Bound Column Zero

9 posts, 2 answers
  1. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 22 Dec 2012 Link to this post

    In Bound Column is Zero how i show it's empty


    <telerik:TreeListBoundColumn DataField="Quantity" HeaderText="Quantity" UniqueName="Quantity"
                                        HeaderStyle-Width="50px" DataFormatString="{0:0}" />

    Thanks Advance,
    Mohamed.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Dec 2012 Link to this post

    Hi,

    I suppose you want to hide the column if its value is 0. Try the following code to achieve your scenario.
    C#:
    protected void RadTreeList1_ItemDataBound(object sender, Telerik.Web.UI.TreeListItemDataBoundEventArgs e)
    {
      if (e.Item is TreeListDataItem)
      {
       TreeListDataItem item = (TreeListDataItem)e.Item;
       if (item["UniqueName"].Text == "0")
       {
          RadTreeList1.GetColumn("UniqueName").Display = false;
       }
      }
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 25 Dec 2012 Link to this post

    Thanks For Your Reply Princy,

    Display property is not in treelist,
    Visible false is working .
    I want to display = false


    Thanks Advance,
    Mohamed .
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Dec 2012 Link to this post

    Hi,

    Unfortunately I cannot replicate the issue at my end. Here is the code that I tried in the version 2012.3.1016.35 which worked as expected.
    aspx:
    <telerik:RadTreeList runat="server" ID="RadTreeList1" DataSourceID="SqlDataSource1"
        AutoGenerateColumns="false"  DataKeyNames="ID"
        ParentDataKeyNames="ReportsTo" onitemdatabound="RadTreeList1_ItemDataBound" >
     <Columns>
       <telerik:TreeListBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID"</telerik:TreeListBoundColumn>
       </Columns>
    </telerik:RadTreeList>
    C#:
    protected void RadTreeList1_ItemDataBound(object sender, Telerik.Web.UI.TreeListItemDataBoundEventArgs e)
    {
      if (e.Item is TreeListDataItem)
      {
       TreeListDataItem item = (TreeListDataItem)e.Item;
       if (item["ID"].Text == "0")
       {
          RadTreeList1.GetColumn("ID).Display = false;
       }
      }
    }

    Thanks,
    Princy.

  6. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 26 Dec 2012 Link to this post

    Hi Mohamed,

    The Display property is not supported for the whole column. You could however set it to all the items of the column using such approach:
    if (item["quantity"].Text == "0")
    {
         (item["quantity"].Style.Add(HtmlTextWriterStyle.Display, "none");
    }


    All the best,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 27 Dec 2012 Link to this post

    Thanks For Reply ,

    See the screen shot

    Thanks Advance,
    Mohamed.
  8. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Dec 2012 Link to this post

    Hi,

    Try modifying the code as shown below.
    C#:
    if (item["Quantity"].Text == "0")
     {
        item["Quantity"].Style.Add(HtmlTextWriterStyle.Display, "none");
     }

    Thanks,
    Princy.
  9. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 27 Dec 2012 Link to this post

    Thanks for your reply Princy

    It's work but next fields assign in quantity field ,
    see the screen shot

    Thanks Advance,
    Mohamed.
  10. Answer
    Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 27 Dec 2012 Link to this post

    Hello Mohamed,

    This is the expected behaviour. If you want the text itself to have Display=false, and the cell to be visible. Then you have to add Label element inside the cell, and remove the original text. Then set the required style to the Label element.

    All the best,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017