We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ejGrid setWidthToColumns

I am trying to set ej Grid column width with setWidthToColumns method. Its not working.  The goal is if user changes the column width, we want to user to reset all columns width to default by clicking a button.

 Here is the code snippet.

                        var grid = $("#FlatGrid").ejGrid("instance");

Please advise.


1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team October 10, 2016 05:37 AM UTC

Hi Arun, 

Thanks for contacting Syncfusion support. 

If you want to change the column width dynamically, use columns method of ejGrid. In this sample we change the column width of an particular column in the button click. 

Find the code example and sample: 

@Html.EJ().Button("buttonnormal").Size(ButtonSize.Normal).Text("Button").ClientSideEvents(e => e.Click("Click")) 
    .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) 
    .Columns(col => 
       col.Field("ShipCity").HeaderText("Ship City").TextAlign(TextAlign.Right).Width(80).Priority(2).EditType(EditingType.Dropdown).ValidationRules(v => v.AddRule("required", true)).Add(); 

function Click(args) { 
        var gridobj = $("#FlatGrid").ejGrid("instance"); 
        gridobj.model.columns[1].width = 100; 
        var columns = gridobj.model.columns[1]; 

Refer to the Help document for the columns method. 

Prasanna Kumar N.S.V 

Live Chat Icon For mobile
Up arrow icon