Is there a way to truncate long text in AspxGridView cells?
I’ve read and implemented this solution. , http://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_CustomColumnDisplayTexttopic
…which of course works BUT only for one column and I need to create this with several columns.
Here is my solution so far
protected void AsPxGridView1CustomColumnDisplayText(object sender, ASPxGridViewColumnDisplayTextEventArgs e)
{
if (e.Column.FieldName != "AnalysisFeedbackAuto") return;
if (e.Value.ToString().Length > 13)
{
var displayText = Regex.Replace(e.Value.ToString(), "<.*?>", string.Empty).Substring(0, 10);
e.DisplayText = string.Concat(displayText, "...");
}
}
Any advice?
Thanks
=== UPDATE ===
Obviously this was the solution
protected void AsPxGridView1CustomColumnDisplayText(object sender, ASPxGridViewColumnDisplayTextEventArgs e)
{
if (e.Column.FieldName == "AnalysisFeedbackAuto"
|| e.Column.FieldName == "AnalysisResults"
|| e.Column.FieldName == "AnalysisAnswers"
)
{
if (e.Value.ToString().Length > 13)
{
var displayText = Regex.Replace(e.Value.ToString(), "<.*?>", string.Empty).Substring(0, 10);
e.DisplayText = string.Concat(displayText, "...");
}
}
}
1 Answer