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

AllowColumnResize - can a minimum column size be enforced?

13 Answers 298 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dean
Top achievements
Rank 1
Dean asked on 16 Oct 2009, 08:09 PM
I have AllowColumnResize="true" and I would like to set a minimum column size for the column resize drag.
I do not like the 'column width must be non negative' message that pops up if I drag the size past 0 or stop the drag at less than 10 pixels. Sometimes It causes error's or put the column into reorder drag mode.
In my application, there is no reason to set the column size below 30 pixels.
I would like the drag to simply not allow the width to get below 30 pixels. This would avaoid the message and also keep my filter row from wrapping the image.
I understand that this may not be possible without changing the source code.
If so, is there anyway to set the column size to 30 whenever the user tries to make it less than 30 (after the drop).
I have tried resizing the column back to the minimum in OnColumnResized, but calling resizeColumn(index,width) from within the call causes the header and item widths to differ (and also causes an error sooner or later).

Any ideas would be appreciated.



13 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 16 Oct 2009, 09:33 PM
You might want to look into the Clipping Cell Content on Resize property discussed in this documentation article. Another resource could be checking out this forum post where a user has implemented the minWidth / maxWidth properties. Although he had an initial issue the basic logic should be there for you.
0
Dean
Top achievements
Rank 1
answered on 19 Oct 2009, 02:54 PM

Thank you for trying. However:

ClientSettings.Resizing.ClipCellContentOnResize does not seem to do anything. Perhaps it has been broken?
If you go to the demo page:
http://demos.telerik.com/aspnet-ajax/grid/examples/client/resizing/defaultcs.aspx
Uncheck 'Clip cell content on resizing' , then resize any column - there appears to be no limit enforced.

And, in IE 7, you get the annoying 'Column width must be non-negative' message whenever you size a column smaller than 14 pixels.
I really need to get rid of this message.

In FireFox 3.5.3, you do not get the message, but if you drag left past 0 pixels, the drag releases and sometimes the column is sized to zero so that it is gone. You have to resize other columns and play around until you can get the drag resize to recover the column.

 

The forum post referenced is for WinForms. I cannot find a MinWidth property for the columns in the ASP control.

 

*********************

I could not find any settings etc. to do what I want. So, I copied and modified the _validateResizeColumnParams method to perform as desired.

 

ClientSettings.ClientEvents.OnMasterTableViewCreated = "onMasterTableViewCreated";  
 
  <script language="javascript" type="text/javascript">  
 
    function validateResize(c, a)  
    {  
      if (isNaN(parseInt(c)))  
      {  
        var b = 'Column index must be of type "Number"!';  
        alert(b);  
        return false 
      }   
      if (isNaN(parseInt(a)))  
      {  
        var b = 'Column width must be of type "Number"!';  
        alert(b);  
        return false 
      }   
      if (c < 0)  
      {  
        var b = "Column index must be non-negative!";  
        alert(b);  
        return false 
      }   
      if (a < 16)  
      { // 16 minimum  
        return false 
      }   
      if (c > (this.get_columns().length - 1))  
      {  
        var b = "Column index must be less than columns count!";  
        alert(b);  
        return false 
      }   
      if (!this._owner.ClientSettings.Resizing.AllowColumnResize)  
      {  
        return false 
      }   
      if (!this.get_columns())  
      {  
        return false 
      }   
      if (!this.get_columns()[c].get_resizable())  
      {  
        return false 
      }   
      return true 
    }  
 
    function onMasterTableViewCreated(sender, eventArgs)  
    {  
      Telerik.Web.UI.GridTableView.prototype._validateResizeColumnParams = validateResize;  
    }  
      </script>  
 
 

I changed (a < 0) to (a < 16) and got rid of the alert message. This may not be what is desirable for someone else.
Changing the '16' to reference a new minColumnWidth property would be nice.

Note: Enforcing a minimum width this way is only useful if real-time resizing is enabled. 

ClientSettings.Resizing.EnableRealTimeResize =

true

 

 

 

The above basically cancels the resize, it would be much better to have the resize continue until the mouse button is released.

Dean

 

 

 

 

0
Dimo
Telerik team
answered on 21 Oct 2009, 07:56 AM
Hello Dean,

The problem with the Javascript alert has been resolved in the Q3 2009 beta release:

http://demos.telerik.com/aspnet-ajax-beta/grid/examples/client/resizing/defaultcs.aspx

As for the minimum width requirement, you can subscribe to the ColumnResizing client event and cancel it, if the new column width is too small.

http://www.telerik.com/help/aspnet-ajax/grid-oncolumnresizing.html

<script type="text/javascript">
 
function ColumnResizing(sender, args)
{
    var newWidth = args.get_gridColumn()._columnResizer._currentWidth;
    if (newWidth < 200)
    {
        args.set_cancel(true);
    }
}
 
</script>
 
<telerik:RadGrid ID="RadGrid1" runat="server">
    <ClientSettings>
        <Resizing AllowColumnResize="true" />
        <ClientEvents OnColumnResizing="ColumnResizing" />
    </ClientSettings>
</telerik:RadGrid>


All the best,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dean
Top achievements
Rank 1
answered on 21 Oct 2009, 05:53 PM
The new demo in IE7 gets rid of the alert and the minimum size is set at a good value, but it should be implemented the same way that

ClientSettings.Resizing.ClipCellContentOnResize = false is implemented. IOW, the resizing should not stop - when dragging back right, the column should resize bigger. In the beta demo, the resizing stops.

There is a problem with the approach - the resize turns into a reorder.

Start resizing 'Contact Title', drag left quickly, all the way to 'Company Name' and release the mouse button.
The 'Contact Title' column is resized to 30 or so pixels and reordered with the 'Company Name' column.
The reorder is definitely not what the user would expect.


0
Dimo
Telerik team
answered on 22 Oct 2009, 09:05 AM
Hi Dean,

Thanks for the feedback, we can improve the UX with this regard in the future.

Kind regards,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dean
Top achievements
Rank 1
answered on 22 Oct 2009, 12:54 PM
Is there going to be a fix for the resize turning into a reorder as discussed above?
0
Dimo
Telerik team
answered on 23 Oct 2009, 08:15 AM
Hi Dean,

Yes, that's what I meant. However, I am afraid we will not be able to include the fix in the coming Q3 release (due in early November).

Greetings,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dean
Top achievements
Rank 1
answered on 23 Oct 2009, 12:38 PM
Can a fix for use with the current release be posted here? Please!

0
Dimo
Telerik team
answered on 23 Oct 2009, 01:26 PM
Hi Dean,

I am afraid we cannot provide a "plug-and-play" fix for this problem. I will let you know when the issue is resolved (after the Q3 release), so that you can download the latest internal build.


Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dimo
Telerik team
answered on 10 Nov 2009, 02:30 PM
Hello Dean,

The resize-to-reorder problem has been fixed, please download the next internal RadControls build once it becomes available (usually within several days).

All the best,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Artem
Top achievements
Rank 1
answered on 16 Feb 2011, 04:58 PM
Hi,

Apparently this resize-turned-reorder problem is still there in version 2010.3.1317. It is easily reproduced in your own resizing demo. I'm 100% with Dean on that, resizing operation should be in progress until the mouse button is released.
0
Pavel
Telerik team
answered on 21 Feb 2011, 01:14 PM
Hi Artem,

The issue is logged in our bug-tracking system and its status can be viewed here.

Greetings,
Pavel
the Telerik team
0
Dave Wolf
Top achievements
Rank 1
Iron
answered on 19 Nov 2013, 06:00 PM
Tags
Grid
Asked by
Dean
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Dean
Top achievements
Rank 1
Dimo
Telerik team
Artem
Top achievements
Rank 1
Pavel
Telerik team
Dave Wolf
Top achievements
Rank 1
Iron
Share this question
or