0

I'm using jqgrid 3.8.2 (I know it's old, I'm going to try to update it after asking this :-) )

I added a couple in-line buttons to my jqgrid, I'm using the default formatter 'actions' and adding the buttons in the loadComplete event. It works fine, I can add my custom buttons, but the thing is I don't need the default buttons, edit and delete, so when I go ahead and hide them with

formatoptions: { editButton:false, delButton:false }

It hides everything; hiding them individually isn't a problem, but both.

Any advice?

Hard Tour Vela
  • 198
  • 3
  • 11
  • The question don't shows inline buttons which you added and which are invisible now. If you don't want to add any buttons which provides `formatter: 'actions'` then it's unclear why you should use the formatter. It's better to add buttons by using your custom formatter. Please describe *what lind of buttons you need to have in the grid*. – Oleg Jul 31 '15 at 05:31
  • Well I did it that way, because I didn't find other options, then I guess I'm gonna research on how to create a custom formatter. Thanks! – Hard Tour Vela Jul 31 '15 at 17:08
  • Look at [the documentation](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter), search for "custom formatter" and "button". If you will not be able to solve the problem yourself you need just describe more clear what you need. The currently text of your question says that you just add some "custom buttons". It's unclear what kind of buttons you added (with text img, span with background images, button, input, ...). What need be done on click on the button (row selected or not, some additional actions and so on). The current code gives no information what you need. – Oleg Jul 31 '15 at 18:00

1 Answers1

0

I solved the issue following Olegs comments and using a custom action formatter

    function myCustomActionFormatter(cellValue, options, rowObject){
//I'm using the rowId so I can identify the button and get an easier access to the rowId itself :)
return '<div id="myCustomButton' + options.rowId  + '" class="myButtonClass">'
}

then, on the loadcomplete event I add the event to the buttons using jquery:

$("#mygrid").jqgrid(... { name='act', width:100, formatter: myCustomActionFormatter}...
,loadcomplete:function(){
$(".myButtonClass").click(function() {//what I want to do});
});
Hard Tour Vela
  • 198
  • 3
  • 11
  • Some remarks: First of all the code contains `loadcomplete` instead of `loadComplete`. Seconds there are more effective way as you posted. You code make **separate** `click` binding to every `
    ` of the cell on **every** reloading of the grid. Instead of that one can use *existing* `click` bunding to the parent: to the ``. One can use `beforeSelectRow` callback to analyse whether `e.target` is the `
    ` or not. It's more effective. See [the answer](http://stackoverflow.com/a/31647943/315935) for more details. By the way you don't need to set `id` on every `
    `.
    – Oleg Aug 05 '15 at 08:39