AnonyMouse
AnonyMouse

Reputation: 18630

jqgrid inline add

Is is correct that jqGrid doesn't currently contain an inline add.

I'm trying to get this working from:

http://www.trirand.net/forum/default.aspx?g=posts&t=212

There are a couple of examples there but they're not working quite as I would like.

Anybody know of a good example

Upvotes: 3

Views: 6239

Answers (2)

soccerenz
soccerenz

Reputation: 142

Try this:

pager: '#id_pager',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"...",
cellEdit: true,
editurl:"....",

beforeSelectRow: function (id) {
    if (id !== lastSel) {
        jQuery("#id_grid").jqGrid('restoreRow', lastSel);
        lastSel = id;
    }
    return true;
},
onSelectRow: function (id, iRow, iCol, e) {
    jQuery("#id_grid").jqGrid('editRow', id, true, function(){
        jQuery("input, select").focus();
    });
    return;
}

And add a button with navButtonAdd:

.navButtonAdd("#id_pager", {
    caption: "",
    buttonicon: "",
    onClickButton: function () {
        var datarow = { id: "", name: "", address: "" };
        var su = jQuery("#id_grid").addRowData("X", datarow, "first");
        if (su) { jQuery("#id_grid").setSelection('X'); }
    },
    position: "last"
});

Don't forget for add editable: true, at every colModel. I hope can help your problem. Thanks

Upvotes: 3

VahidN
VahidN

Reputation: 19156

Also you can try the inlineNav's features:

$grid.jqGrid('navGrid', '#pager', {add: false, edit: false, del: false});
$grid.jqGrid('inlineNav', '#pager', {addParams: {position: "last"}});

More info

Upvotes: 0

Related Questions