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.
Unfortunately, activation email could not send to your email. Please try again.

ejGrid setWidthToColumns

Thread ID:

Created:

Updated:

Platform:

Replies:

126330 Oct 7,2016 12:48 PM Oct 10,2016 01:37 AM ASP.NET MVC 1
loading
Tags: Grid
Arun Gandhi
Asked On October 7, 2016 12:48 PM

Hello,
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");
                        grid.setWidthToColumns();
                        grid.refreshContent();


Please advise.

Thanks

Prasanna Kumar Viswanathan [Syncfusion]
Replied On October 10, 2016 01:37 AM

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")) 
 
@(Html.EJ().Grid<object>("FlatGrid") 
    .Datasource((IEnumerable<object>)ViewBag.datasource) 
    .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) 
    ------------------ 
   .AllowPaging() 
    .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]; 
        gridobj.columns(columns); 
    } 


Refer to the Help document for the columns method. 


Regards, 
Prasanna Kumar N.S.V 
 


CONFIRMATION

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.

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.

;