Hi,
Can you tell me if there is a way to limit the amount of text shown in rad grid? For example; a particular data field has a string of text about 200 characters in length, but on the actual data grid I only want to show the first 50 characters in the data column. How would I do that?
Looking forward to assistance.
Thanks,
Ron.
Can you tell me if there is a way to limit the amount of text shown in rad grid? For example; a particular data field has a string of text about 200 characters in length, but on the actual data grid I only want to show the first 50 characters in the data column. How would I do that?
Looking forward to assistance.
Thanks,
Ron.
5 Answers, 1 is accepted
0

Jayesh Goyani
Top achievements
Rank 2
answered on 07 Aug 2011, 05:33 PM
Hello,
Let me know if any concern.
Thanks,
Jayesh Goyani
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Name"
UniqueName
=
"Name"
>
</
telerik:GridBoundColumn
>
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = e.Item
as
GridDataItem;
if
(item[
"Name"
].Text.Length > 200)
{
item[
"Name"
].Text = item[
"Name"
].Text.Substring(0, 200);
}
}
}
Let me know if any concern.
Thanks,
Jayesh Goyani
0

Rakesh Gupta
Top achievements
Rank 2
answered on 08 Aug 2011, 09:35 AM
Hello,
You can achieve this by using following code.
.aspx:
.aspx.cs
Above code will display first 50 characters if the characters are more than 50.
Let me know for any concerns.
--
Thanks & Regards,
Rakesh T. Gupta
You can achieve this by using following code.
.aspx:
<telerik:GridTemplateColumn HeaderText=
"Short Description"
DataField=
"Description"
SortExpression=
"Description"
AllowFiltering=
"true"
UniqueName=
"Description"
Visible=
"true"
>
<HeaderStyle HorizontalAlign=
"Left"
/>
<ItemTemplate>
<asp:Label runat=
"server"
ID=
"lblDescription"
Text=
'<%# Eval("Description") %>'
></asp:Label>
</ItemTemplate>
<ItemStyle Wrap=
"True"
HorizontalAlign=
"Left"
/>
</telerik:GridTemplateColumn>
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
Label lblDescription= (Label)e.Item.FindControl(
"lblDescription"
);
if
(lblDescription.Text.Length > 50)
lblDescription.Text = lblDescription.Text.SubString(0,50);
}
}
Above code will display first 50 characters if the characters are more than 50.
Let me know for any concerns.
--
Thanks & Regards,
Rakesh T. Gupta
0

Jayesh Goyani
Top achievements
Rank 2
answered on 08 Aug 2011, 09:45 AM
Hello Rakesh.
Its also work but if you take one more Lable to showing the data then it will affect the Grid's performance (on Live Server).
Please compare the page source code in both sample.
Thanks,
Jayesh Goyani
Its also work but if you take one more Lable to showing the data then it will affect the Grid's performance (on Live Server).
Please compare the page source code in both sample.
Thanks,
Jayesh Goyani
0

Harish
Top achievements
Rank 1
answered on 07 Jul 2015, 10:44 AM
Hi Jayesh,
I want the same scenario but only thing I am using RadEditor control.
In RadEditor control I have some formatted test(Bold,Italic). Now from the formatted content I want to show the only first 50 character. If I will try the above code which mentioned you It will not bind the formatted text.
I am getting from database
Content Saved in Database:
<strong><em><span style="font-size: 20px;
text-decoration: underline; color: #ff0000; background-color:
#ffc000;">WOW <span style="color: #000000; background-color:
#ffffff;">12356432569874563215346985763259874561235478965324</span></span></em></strong>
How to achieve this ?
Thanks,
Harish P
0
Hi Harish,
The question you posted has already been answered in the following forum thread: http://www.telerik.com/forums/radeditor-shows-only-50-character-from-content. I would recommend continuing the discussion there as it will be easier to track the information on the case when it is in one place.
Regards,
Slav
Telerik
The question you posted has already been answered in the following forum thread: http://www.telerik.com/forums/radeditor-shows-only-50-character-from-content. I would recommend continuing the discussion there as it will be easier to track the information on the case when it is in one place.
Regards,
Slav
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items