Mark

Forum Replies Created

Viewing 14 replies - 91 through 104 (of 104 total)
  • Author
    Replies
  • in reply to: remove multiselect ckbox in grid header #88504
    Mark
    Participant

    There's no direct way that I can see.

    You do get an onSelectAll event right after the rows have all been selected or all deselected – so you /could/ use that and deselect rows “after the fact” as it were. That would probably work.

    Or, you could try something like $('#cb_jqg', $(mygrid)).hide() to hide the checkbox. The only problem there is that the id of the checkbox ('cb_jqg') is not documented – so it could change.

    As an aside, I think it should be changed, because right now if you have two grids, both checkboxes have the same id. Everything seems to work – but its not supported by any standard. It would be better if each grid had a unique id for the checkbox.

    Mark

    in reply to: Minimize Grid Trigger #88501
    Mark
    Participant

    However, I would still like to know how to click the minimize button via script.


    Looks like $(“.ui-jqgrid-titlebar-close”, $(mygrid)).click() should do it…

    Mark

    Mark
    Participant

    Couldnt you use the formatCell or beforeEditCell event instead?

    in reply to: More control over click/select behavior #88470
    Mark
    Participant

    In case anyone tries to use it, the return condition should be:

    if (!ptr.length || (td.tagName == 'INPUT' && !scb) || td.tagName == 'A') {
    return true;
    }

    Mark

    in reply to: Selects returning option string instead of value #88469
    Mark
    Participant

    Im having problems with unformat and getRowData (using latest from github).

    It looks to me like getRowData is broken, but perhaps Im missing something obvious.

    getRowData calls: $.unformat($(this).html(),{colModel:$t.p.colModel},i)

    Note, the first parameter is the html contents of the cell, as a string.

    But $.unformat then uses $(cellval).text() – which for me is always returning the empty string (since, in general cellval wont be a selector that matches anything on the page!).

    Im guessing that getRowData should just pass in this (it fixes the problem for me)

    Mark

    in reply to: More control over click/select behavior #88465
    Mark
    Participant

    So following up to my own post… after studying the grid code I found a way to do it – although its something of a hack, and rather fragile.

    If beforeSelectRow could be passed the event object, and the column ix, I think I could do everything I want without any trickery.

    For anyone else interested in a grid that supports shift-click to select ranges, ctrl-click to toggle rows, and handles clicks on editable fields smartly, the code follows. To use it set “multiselect:true,beforeSelectRow:function(){return false;}” in the grid options, and then add the handler as follows:

    $(mygrid).bind(“click”,$(mygrid),multiSelectHandler);

    where multiselectHandler is:

    function multiSelectHandler(e) {
    var grid = e.data;
    var ts = grid[0], td = e.target;
    var scb = $(td).hasClass(“cbox”);
    var ptr = $(td).parents(“tr.jqgrow”);
    if (!ptr.length || td.tagName == 'INPUT' || td.tagName == 'A') {
    return true;
    }
    var sel = grid.getGridParam('selarrrow');
    var sid = ptr[0].id;
    var selected = $.inArray(sid, sel) >= 0;
    if (e.ctrlKey || (scb && (selected || !e.shiftKey))) {
    grid.setSelection(false,true,ptr);
    } else {
    if (e.shiftKey) {
    var six = grid.getInd( sid);
    var min = six, max = six;
    $.each(sel, function() {
    var ix = grid.getInd( this);
    if (ix < min) min = ix;
    if (ix > max) max = ix;
    });
    while (min <= max) {
    var row = ts.rows[min++];
    var rid = row.id;
    if (rid != sid && $.inArray(rid, sel)<0) {
    grid.setSelection( false, false, $(row));
    }
    }
    } else if (!selected) {
    grid.resetSelection();
    }
    if (!selected) {
    grid.setSelection( false, true, ptr);
    } else {
    var osr = grid.getGridParam('onSelectRow');
    if ($.isFunction(osr)) {
    osr(sid, true);
    }
    }
    }
    }

    in reply to: Namespace pollution #88431
    Mark
    Participant

    No – you express yourself very clearly. Apparently I dont Laugh

    If you look at my changes (better yet, try them out), you will see that existing code works *without any modification*.

    In addition, you can use the new syntax ( $(selector).jqGrid(“method”,args) rather than $(selector).method(args) ). But its not required.

    The only time users need to make a change is if they want to get rid of the old syntax, in order to prevent the existing namespace pollution.

    In that case, they set $.jgrid.no_legacy_api=true, and then they *only* get the new syntax.

    So once again – there is /no/ breakage of existing code with these changes.

    And yes – of course there are many more functions that should be fixed – I just targetted grid.base.js to show you where I was going, and to see what you thought.

    Mark

    in reply to: jQuery.css returns a string #88373
    Mark
    Participant

    Sorry, you're right… except that there appears to be a minor bug in jQuery.

    If you're setting height or width, and you pass in a -ve value, (eg $(“#foo”).css(“width”, “-4px”), then it goes through the “undefined” case in the above, which then /returns/ the width, rather than setting the width, and returning a jQuery.

    That's what was happening, and I just jumped to the conclusion that css always returned a string.

    So now I need to track down how colModel.width gets to be < 0. I think it has something to do with autowidth.

    In any case, its probably my bug (in that it doesnt show up in firefox) – but I'd still say that its a good idea not to chain the css method when setting width/height by name unless you're certain the width/height is >= 0.

    Mark

    in reply to: Cell Values when select is used #88365
    Mark
    Participant

    Not yet ready to test any of this, sorry, but I've looked over the changes.

    Not much to say, except that I think its doing more or less what /I/ will want (once I get there!).

    A couple of observations:

    In grid.celledit.js, lines 119 and following:

in reply to: Namespace pollution #88362
Mark
Participant

Hi Tony,

Yes – my solution doesnt (shouldnt!) break anything – unless the user explicitly asks for the old api to be removed.

I've modified 3.5.2, and put it at http://myosotissp.com/jqGrid-3.5.2x.tgz to show you exactly what Im thinking.

For this, Ive only moved the methods defined in grid.base.js, but I've rewritten all calls to those methods (from anywhere) to use the “new” syntax.

If you use this as a straight replacement for 3.5.2, any existing code should continue to work (mine does!). In addition you can write calls to any method defined in grid.base.js using the new syntax, eg:

in reply to: Namespace pollution #88318
Mark
Participant

Hi Tony,

Thanks for the feedback. Sorry to be so slow to respond – I didnt notice your post until now.

I've just looked at the changes, and as you say, its an improvement, but there's still a lot of names added to both $ and $.fn.

I realized my proposed solution – to extend $.fn.jqGrid rather than $.fn – doesnt quite work (after trying it out on one of the methods!), because when you call $(selection).jqGrid.showCol() (for example), showCol gets called, but with the wrong “this” parameter (the jqGrid object, rather than the jQuery object).

It looks like the “standard” way to do this in jQuery UI is to instead do something like $(selection).jqGrid(”showCol”).

I think we could achieve this by following the approach I outlined in my original post, and modifying $.fn.jqGrid to do something like:

if (typeof p == “string”) {

in reply to: Selects returning option string instead of value #88303
Mark
Participant

Isnt there an oversight in $.unformat? All the built in formatters are handled there, except for “select”.

Also, shouldn't there be an equivalent to getRowData that /does/ unformat the data (or did I miss it)? I would have expected it to be the default… the data gets formatted when its put into the grid, shouldnt it be unformatted when you take it out? Formatting is pure presentation – Im normally interested in the data value, rarely how its being displayed.

Mark

Mark
Participant

OlegK said:

Post edited 15:47 – 16/08/2009 by OlegK


Mark
Participant

Note that you can turn off caching via headers, and doing it this way has a significant advantage over the nd approach:

You can still use ETag to return a “304 Not Modified” response from the server. With the nd parameter you never get that opportunity.

Mark

Viewing 14 replies - 91 through 104 (of 104 total)

Stay connected with us in your favorite flavor!