what the purpose of position:"last" in jqgrid?
I have question about jqgrid, what the purpose of position:"last" in jqgrid?
for more details, this is my code :
.navButtonAdd("#rowsTransaksi",{
caption:"",
buttonicon:"",
onClickButton:function(){
var datarow = {acctId: "", currency: "", amount: ""};
//var su=jQuery("#Transaksi").addRowData(datarow,"last");
var su=jQuery("#Transaksi").addRowData("X",datarow,"last");
if(su) { jQuery("#Transaksi").setSelection('X') }
}, ***position:"last"***
Help me please, tell m开发者_运维百科e about explanation for my question.. =) Thanks.
There are some more important problem in your code. The line addRowData("X",datarow,"last")
use always the same "X" value as the rowid, but id must be unique. I suggest you to use $.jgrid.randId()
method instead which generate new unique id.
Your code could be rewritten as the following:
var myGrid = $("#Transaksi");
myGrid.jqGrid('navButtonAdd', "#pager", {
caption: "",
buttonicon: "ui-icon-plus",
title: "Add empty row",
onClickButton: function () {
var datarow = { acctId: "", currency: "", amount: "" },
newId = $.jgrid.randId();
if (myGrid.addRowData(newId, datarow, "last")) {
myGrid.setSelection(newId);
}
},
position:"first"
});
which will be place the new button which looks like "+" on the first place (before refresh button on the picture below)
see the demo.
From the jqGrid documentation.
position: (“first” or “last”) the position where the button will be added (i.e., before or after the standard buttons).
精彩评论