开发者

Telerik mvc grid and fixed width column

all my grids will have in the first column, some image links to edit, delete and open the record.

I can't get this column to be fixed at 80 pixels.

Here is my code:

@(Html.Telerik().Grid(Model)
    .Name("Grid")
    .DataKeys(keys => keys.Add(c => c.Handle))         
    .DataBinding(dataBinding => dataBinding
        .Ajax()
        .Select("AjaxPesquisar", "Especialidade")
        .Update("AjaxAtualizar", "Especialidade")
        .Delete("AjaxDelete", "Especialidade"))
    .HtmlAttributes(new { @class = "grid-padrao" })
    .ClientEvents(events => events
        .OnDataBound("atualizarCss")
    )
    .Columns(columns =>
    {
        columns.Template(@<span><a class="formatacao" href="/Especialidade/Details/238" image="show"></a><a class="formatacao delete-link" href="/Especialidade/AjaxDelete/238" image="delete"></a><a class="formatacao" href="/Especialidade/Edit/238" image="edit"></a></span>).Width(80);
        columns.Bound("Descricao").Title("Descrição");
        colum开发者_StackOverflow中文版ns.Bound("Handle").Title("Código");


    })        
    .Pageable()
    .Sortable()

    )


Column widths work best if the table-layout CSS setting of the table is set to fixed. You can either make your grid Scrollable() or use the following CSS:

<style>
   .t-grid table
   {
      table-layout: fixed;
   }
</style>

You can find more info about tables here.


I have the same issue too! What I did to get it work is to add:

columns.Bound(o => o.YourColumn)
.HtmlAttributes(new{@style="display:inline-block;width:80px;" });

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜