This is a migrated thread and some comments may be shown as answers.

Resizing the columns to their default

5 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Reid
Top achievements
Rank 2
Reid asked on 31 May 2016, 06:10 PM

I have a scenario where I need a way for the user to cancel an insert once they have chose to insert a new row.

The configuration is InCell editing with a custom "save" button and a custom "add" on top of the view.  So the grid is in batch edit mode and is working fine other than when the user decides to insert a row.  If I place a default "Cancel" command that cancel button will be in every row.  That is one problem.

So I decided to have a hidden column at the end of the grid with a client template containing a "Cancel" button.

When they insert a new row I hook the onEdit event of the grid and make the column visible.  But in doing so all of the column widths get whacked out.  I searched a bit to find a resize row method but it is not working.

 

function resizeColumnDefaults() {
    debugger;
    resize(0, 250);
    resize(2, 100);
    resize(3, 100);
    resize(5, 100);
    resize(6, 100);
    resize(8, 120);
    resize(9, 300);
    resize(10, 75);
    resize(11, 75);
    resize(13, 75);
}
 
 
function resize(idx, width) {
    $("#Grid .k-grid-header-wrap") //header
       .find("colgroup col")
       .eq(idx)
       .css({ width: width });
 
    $("#Grid .k-grid-content") //content
       .find("colgroup col")
       .eq(idx)
       .css({ width: width });
}
 
 
function onEdit(e) {     
    var grid = $("#Grid").data("kendoGrid");
    grid.showColumn(11);
    resizeColumnDefaults();      
 
    }

 

Can someone offer a solution?

 

Thanks,

Reid

 

 

5 Answers, 1 is accepted

Sort by
0
Galin
Telerik team
answered on 02 Jun 2016, 02:08 PM
Hi Reid,

If I understand correctly your scenario you want to avoid the resizing of the columns on showing/hiding the
additional column. In this case I suggest you to enable the scrolling as it shown in this sample:
http://dojo.telerik.com/EsihU

Regards,
Galin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Reid
Top achievements
Rank 2
answered on 03 Jun 2016, 10:35 AM

Hello,

 

Actually I wanted to resize the columns to their default widths.  This was necessary because when I executed code to show a column that was hidden by default all the preset widths were not applied and the columns sort of crunched up together.

We have since changed the UI design and the column was not needed.  But why the code above does not work is still unknown.

0
Galin
Telerik team
answered on 06 Jun 2016, 08:50 AM
Hi Reid,

I tried your code and it works as expected. For reference I modified the Dojo sample and insert inside it.
I guess there is a something in your code which breaks the functionality.


Regards,
Galin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Reid
Top achievements
Rank 2
answered on 10 Jun 2016, 11:51 AM

That is the demo I adapted my code from.  It does not however work on my view.

 

Thanks though

0
Galin
Telerik team
answered on 13 Jun 2016, 01:52 PM
Hi Reid,

Could you elaborate on your queries so we can get a better understanding of your needs? I would appreciate it, if you could isolate the problem in a simple running project so that I can examine it locally.


Regards,
Galin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Reid
Top achievements
Rank 2
Answers by
Galin
Telerik team
Reid
Top achievements
Rank 2
Share this question
or