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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ejGrid setWidthToColumns

Thread ID:





126330 Oct 7,2016 04:48 PM UTC Oct 10,2016 05:37 AM UTC ASP.NET MVC 1
Tags: Grid
Arun Gandhi
Asked On October 7, 2016 04:48 PM UTC

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.


Prasanna Kumar Viswanathan [Syncfusion]
Replied On 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 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon