Hi Henryk,
We regret for the delayed response.
The reported issue raised due to non-existence of grid in the View. We suggest to use the following code snippet
to validate the Grid existence.
[.js]
$('#Grid1').length>0
Refer the below code snippet, which illustrates this.
[.js]
Sys.Application.add_load(function() {
//Set columnIndex, width
var columnIndex = 2;
var colWidth = 450;
//Validate the Grid appearance
if ($('#Grid1').length > 0) {
//Find the table header cells
var th = $($($('#Grid1').find("thead:first")[0]).find("tr:last")).find("th");
//set the column header width
var widthDiff = colWidth - th[columnIndex].offsetWidth;
th[columnIndex].style.width = colWidth + "px";
//find the div element inside the header and update the width [Note: calculate the padding
values,here padding value is 11]
var div = $(th[columnIndex]).find("div");
$(div[0]).width(colWidth - 11 + "px");
//Update the Grid width by the modified column width
$("#Grid1")[0].style.width = parseInt($("#Grid1")[0].style.width) + widthDiff + "px";
}
});
Please refer the updated sample from the below link.
http://files.syncfusion.com/support/grid_mvc/v7.4.0.20/F89659/MVC_SampleGrid.zipPlease let us know if you have any concerns.
Regards,
M. Balaji