grid columns should be resizable within the available width but not beyond

1 Answer 155 Views
Grid
ashutosh
Top achievements
Rank 1
Iron
Veteran
ashutosh asked on 23 Sep 2021, 11:03 AM

Hi Team,

is it possible to limit to what is the max width to which user can resize a column, such that the column does not go beyond the visible area and does not introduce scrollbar.

i know that scroll and resize goes hand in hand and hence i am not able to make that work.

any help here is appriciated.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 28 Sep 2021, 06:25 AM

Hello Ashutosh,

There is no built-in property limiting the width of the column upon resizing, however, this can be achieved with custom login in the columnResize event handler.

columnResize: function(e) {
          $("#grid colgroup col").each(function () {
            if ($(this).width() > 380) {
              $(this).css("width", "380px");
            }
          })
        }

Here is a Dojo demo I prepared demonstrating this:

For a single column the above will look like the following:

columnResize: function(e) {
          $("#grid colgroup").each(function() {
            if($(this).width() < 380){
                $(this).find(":nth-child(1)").css("width","380px"); //target the second column
            }
        }
    )
        }

Let me know if you have any uqestions.

Regards,
Nikolay
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
ashutosh
Top achievements
Rank 1
Iron
Veteran
Answers by
Nikolay
Telerik team
Share this question
or