Hi,
Whe I hide columns in a sub-grid I get problems with the look of the sub-grid. The reason seems to be that I hide the last column that does not have the width set (to make this column take up the remaining space in the row).
The template for the sub-grid from the cshtml page:
<script id="utförseltemplate" type="text/x-kendo-tmpl">
@(Html.Kendo().Grid<UtförselViewModel>()
.Name("grid_#=Id#")
.TableHtmlAttributes(new { @class = "ansokan-produkter-utforsel-subgrid" })
.Columns(columns =>
{
columns.Bound(p => p.Id).Hidden(true);
columns.Bound(p => p.UtförselDiarieNummer).Title("Diarienummer").Width(150);
columns.Bound(p => p.Datum).Format("{0:yyyy-MM-dd}").Title("Utförseldatum").Width(120);
columns.Bound(p => p.DelKvantitet).Title("Levererad kvantitet").Width(120);
columns.Bound(p => p.Enhet).Title("Enhet");
})
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(r => r.Action("ProduktUtförslarRead", "Giltiga", new { produktId = "#=ProduktId#", ansökanProduktId = "#=Id#" }))
.Sort(sort => sort.Add(r => r.Datum).Descending())
)
.Events(events => events.DataBound("UtforslarDataBound"))
.ToClientTemplate()
)
</script>
Part of the javscript ondatabound:
if (some condition) {
this.hideColumn(3);
this.hideColumn(4);
}
When I hide this column the grid looks chopped off. I guess that I
need to set the column width in the javascript, but I have not been able
to figure out how.
Can you help me set the column width in the javascript or set the width of the whole sub-grid?
Best regards,
Henrik