This is a migrated thread and some comments may be shown as answers.

In Bound Column Zero

8 Answers 113 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 22 Dec 2012, 10:26 AM
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.

8 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Dec 2012, 05:35 AM
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.
0
mohamed
Top achievements
Rank 1
answered on 26 Dec 2012, 04:59 AM
Thanks For Your Reply Princy,

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


Thanks Advance,
Mohamed .
0
Princy
Top achievements
Rank 2
answered on 26 Dec 2012, 09:12 AM
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.

0
Vasil
Telerik team
answered on 26 Dec 2012, 09:14 AM
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.
0
mohamed
Top achievements
Rank 1
answered on 27 Dec 2012, 07:22 AM
Thanks For Reply ,

See the screen shot

Thanks Advance,
Mohamed.
0
Accepted
Princy
Top achievements
Rank 2
answered on 27 Dec 2012, 07:39 AM
Hi,

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

Thanks,
Princy.
0
mohamed
Top achievements
Rank 1
answered on 27 Dec 2012, 07:57 AM
Thanks for your reply Princy

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

Thanks Advance,
Mohamed.
0
Accepted
Vasil
Telerik team
answered on 27 Dec 2012, 12:50 PM
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.
Tags
TreeList
Asked by
mohamed
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
mohamed
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or