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

customized string in columns

3 Answers 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chap
Top achievements
Rank 1
Chap asked on 25 Mar 2013, 06:05 AM
Hi,

I am using a rad grid in a web form. My requirement is show customize text in columns. 

suppose this is the real value binds to grid
"Aua7o0qnW-8n1nrHtR_1I0wg4kHD59"

I  want to show only first 10 characters and 3 dots
"Aua7o0qnW-..."

I have tried with dataFormatString. But couldn't get result that I wanted.

Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 25 Mar 2013, 06:37 AM
Hi,

Try the following code.
C#:
void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            if (item["Uniquename"].Text.Length > 10)
            {
                item["Uniquename"].Text = item["Uniquename"].Text.Substring(0, 5) + "...";
            }
  }
}

Thanks,
Princy.
0
Chap
Top achievements
Rank 1
answered on 25 Mar 2013, 08:24 AM
thanks for your reply, Can't we do this in client side. I mean using dataFormatString?
0
Accepted
Kostadin
Telerik team
answered on 28 Mar 2013, 08:12 AM
Hi Chap,

I am afraid there's not much formatting that can be applied to a string by using DataFormatString. I would suggest you to use the Princy's approach in order to achieve your requirement.

Regards,
Kostadin
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
Grid
Asked by
Chap
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Chap
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or