3

I am creating a custom button by using "navButtonAdd". I want to enable/disable this button. How do I do this?

grid.navButtonAdd("#pg_List1_toppager", { caption: "", buttonicon: "icon-archive", onClickButton: customSearch, position: "first", title: "Archive", cursor: "pointer", disabled: "disabled" });
DisplayName
  • 3,093
  • 5
  • 35
  • 42
ZSH
  • 631
  • 5
  • 16
  • 36

1 Answers1

10

First of all I would recommend you to use id option of navButtonAdd which allows assign id attribute to the button. It makes easier to address the button later. To disable the button you can add class "ui-state-disabled" to it. To enable the button you can remove buttons.

I would recommend you to examine the demo from the answer and another demo from the answer which hide/show non-active buttons of navigator bar.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • WOOOW you're like a Superman :D.I change grid.navButtonAdd("#pg_List1_toppager", { id:"btn" }) and when i use $('#btn' + gid).addClass('ui-state-disabled') not work – ZSH Jul 03 '13 at 09:59
  • 1
    @ZSH: Why you use `+ gid` after `'#btn'` in the selector? You have to use `$('#btn' + gid).addClass('ui-state-disabled')` only if you use `grid.navButtonAdd("#pg_List1_toppager", { id:"btn" + gid, ...})`. If you use just `id:"btn"` then your code should be `$('#btn').addClass('ui-state-disabled');` – Oleg Jul 03 '13 at 10:12