Resizing the columns to their default

6 posts, 0 answers
  1. Reid
    Reid avatar
    317 posts
    Member since:
    Oct 2008

    Posted 31 May Link to this post

    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

     

     

  2. Galin
    Admin
    Galin avatar
    526 posts

    Posted 02 Jun Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Reid
    Reid avatar
    317 posts
    Member since:
    Oct 2008

    Posted 03 Jun in reply to Galin Link to this post

    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.

  5. Galin
    Admin
    Galin avatar
    526 posts

    Posted 06 Jun Link to this post

    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
  6. Reid
    Reid avatar
    317 posts
    Member since:
    Oct 2008

    Posted 10 Jun in reply to Galin Link to this post

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

     

    Thanks though

  7. Galin
    Admin
    Galin avatar
    526 posts

    Posted 13 Jun Link to this post

    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready