如何设置ASP.net MVC Grid Column文本长度?

时间:2016-02-24 07:54:19

标签: c# asp.net-mvc-5

我想设置MVC网格列文本长度。

就像例子一样。如果文字是:

" Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam consectetur venenatis blandit. Praesent vehicula, libero non pretium vulputate, lacus arcu facilisis lectus, sed feugiat tellus nulla eu dolor. Nulla porta bibendum lectus quis euismod. Aliquam volutpat ultricies porttitor. Cras risus nisi, accumsan vel cursus ut, sollicitudin vitae dolor. Fusce scelerisque eleifend lectus in bibendum. Suspendisse lacinia egestas felis a volutpat. "

然后Grid Column显示如下:“ Lorem ipsum dolor sit amet ...

我用Substring尝试了它,但它给出了错误。 像这样

  

grid.Column(“TicketDescription”.Substring(0,30)+'....',标题:“描述”,样式:“charlength”)

对此有任何建议 帮助我。

1 个答案:

答案 0 :(得分:3)

你应该使用'text-overflow:ellipsis;' css造型:

将下一个样式添加到您的单元格

<ul id="sidebar-lists">
<span id="emp-dep-lists">
    {{#each associateList}}
        &lt;li&gt;
            &lt;a href="#"&gt;
                {{#if image}}
                    &lt;img src="{{image}}" height="35" width="35"&gt;
                {{else}}
                    &lt;img height="35" width="35" src="/assets/images/black-user-shape.svg"&gt;
                {{/if}}
                &lt;span class="title"&gt;{{name}}&lt;/span&gt;
            &lt;/a&gt;
        &lt;/li&gt;
    {{/each}}
</span>
<li>
  <a href="#">
    <img height="35" width="35" src="http://localhost:8084/assets/empImg/spot_1241.jpeg">
      <span class="title">John</span>
  </a>
</li>
</ul>