Oracle Tip: Apply RowNum after Order By

January 22, 2010 by Reboot · Leave a Comment 

Ordering a resultset which contains a rownum statement will order the resultset which is return by the rownum.

e.g. the query:

select * from mytable where rownum <= 10 order by id desc

does not have to return the last 10 records.

See also:
http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html

Think of it as being processed in this order:
1. The FROM/WHERE clause goes first.
2. ROWNUM is assigned and incremented to each output row from the FROM/WHERE clause.
3. SELECT is applied.
4. GROUP BY is applied.
5. HAVING is applied.
6. ORDER BY is applied.

*sighs* Refactoring a RIA application (again) to make it work for IE.

January 15, 2010 by Reboot · Leave a Comment 

Ran into this one for example:

“The onchange event can be attached (inline or as an event handler) to any form element. It fires whenever the value of the form field changes. Unfortunately, the behavior is a bit strange in IE, in that for a checkbox, or a radio button field, the event doesn’t fire when it is supposed to (right when you click the option you want to choose), but instead it only fires, when you click elsewhere on the page/form, or if you explicitly call blur(); on the field.”

http://norman.walsh.name/2009/03/24/jQueryIE

Also got some styling issues with the jqGrid, and no, that’s NOT a **** up by jqGrid. It’s IE failing on proper CSS support, AGAIN.

Why do I even bother to make it fit for such a PATHETIC browser which is probably NEVER getting better.

I also yanked out the jQuery LiveQuery plug-in which should have increased performance instead of making it slower ?!?
Didn’t notice that in other browsers.

Toggle visibility jqGrid from outside the grid.

January 15, 2010 by Reboot · Leave a Comment 

The only way I found working:

// Hide the grid when it is visible.
if ( $('#yourtableid).getGridParam('gridstate') == 'visible') {
   $('#gview_yourtableid a.ui-jqgrid-titlebar-close.HeaderButton').trigger('click');
}

Any other thoughts on this are more than welcome!

Couldn’t find a jqGrid function to do it “properly” from outside the grid.
Setting the gridstate and refreshing didn’t work ?!?

Having fun in Lazytown.

January 15, 2010 by Reboot · Leave a Comment 

My nickname is RebootGPF and no, that’s not my voice being frustrated :)

Bug: jQuery validation plug-in 1.6

January 14, 2010 by Reboot · 1 Comment 

Line 177 from the jQuery validation plug-in (1.6) contains:

   this.settings = $.extend( {}, $.validator.defaults, options );

This line will actually cause a bug if the page contains multiple forms of which input elements have the same name.
What happens is that the defaults are not copied deep enough which leaves (at least one) reference to the properties in the defaults property.
The reference to the “rules” property will cause every created form validation to add rules to this “defaults.rules” property.
Hence some forms get unnecessary or unwanted rules.Fix it by changing line 177 into:

   this.settings = $.extend(true, {}, $.validator.defaults, options );

Which performs a deep copy.

The next javascript snippet shows how a reference like this might cause issues (unless that’s what you really want).

$(document).ready(function() {
    options =  {
        property : 'normal prop',
        objectproperty : {prop1: 'prop1'}
    };

    var copy1 = $.extend({},options);
    var copy2 = $.extend({},options);

    //Adding to the objectproperty of the first copy will also alter the second :(
    copy1.objectproperty.prop2 = 'prop2';

    if (copy2.objectproperty.prop2) {
        alert('Without deepcopy there might possibly be unwanted object references!');
    }

    if (options.objectproperty.prop2) {
        alert('Hey look, also a new default option!');
    }
});

$(document).ready(function() {
    options =  {
        property : 'prop',
        objectproperty : {prop1: 'prop1'}
    };

    // target = $.extend(true,{}, source1 , source2, ..., sourceN)
    var copy1 = $.extend(true,{},options);
    var copy2 = $.extend(true,{},options);

    //alert('ready');
    copy1.objectproperty.prop2 = 'prop2';

    if (copy2.objectproperty.prop2) {
        alert('Not the place to be!');
    } else {
        alert('Now we got a nice deep copy without leftover object references!');
    }
});

http://plugins.jquery.com/node/12411

HAPPY NEW YEAR

January 4, 2010 by Reboot · Leave a Comment 

^_^