Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to get scrollbar visibility in ListGrid

    Hi there,

    I'm facing a little problem with ListGrids horizontal scrollbar. I need to find out if it is showed or not at runtime. Is there any simple way how to find it out?

    Currently I'm using workaround so that I summarize widths of all showed collums and then compare it with width of whole ListGrid but there is a problem when I use autofit for collums - in this case I wont get collums widths but just null values...

    I am using SmartGWT 3.1.

    I will appreciate any advice, thanks

    Honza

    #2
    How I solved it...

    Hello,

    first of all I should apologize for creating this thread in a wrong forum, maybe some of the admins can move it to the second one that is aimed on developing in SmartGWT...

    Now If someone would ever come into same situation as me there is how I solved it. Everything I needed to do was to search for some javascript variable that holds information about whether the horizontal scrollbar is visible at the moment or not... after some searching I have found out that javascript instance of the ListGrid is created of a few other components and that body component has exactly what I need - its variable "hscrollOn". So I created native method and it works like a charm... here it is:

    Code:
        /** Determines whether the horizontal scrollbar is visible or not. Uses the
         * javascript value of variable ListGrid.body.hscrollOn.
         * 
         * @param obj javascript object representing instance of {@link LogListGrid}
         *        class
         * @return whether the horizontal scrollbar of list grid is currently
         *         visible or not */
        public static native boolean isHScrollbarVisible(JavaScriptObject obj)/*-{
    		var body = obj.body;
    		if (body == null) {
    			// This should not happen -> means that ListGrid has no body at all!
    			return false;
    		} else {
    			// Should occurr normally
    			console.log(body.hscrollOn);
    			return body.hscrollOn;
    		}
        }-*/;
    hope it helps someone ;)
    Last edited by stuchy; 22 May 2013, 02:36.

    Comment

    Working...
    X