jqxgrid按钮没有触发

时间:2014-08-13 09:52:01

标签: c# asp.net visual-studio-2010 jqxgrid

我在我的jqxgrid页面上使用了三个按钮:

rendertoolbar: function (toolbar) {
                  var me = this;
                  var container = $("<div style='margin: 5px;'></div>");
                  toolbar.append(container);
                  container.append('<input id="updaterowbutton" type="button" value="Afficher le détail du constat" />');
                  container.append('<input id="addrowbutton" type="button" value="Ajouter un nouveau constat" runat="server"/>');
                  container.append('<input id="deleterowbutton" type="button" value="Supprimer le constat sélectionné" runat="server" />');
                  $("#addrowbutton").jqxButton();
                  $("#deleterowbutton").jqxButton();
                  $("#updaterowbutton").jqxButton();

                  // update row.
                  $("#updaterowbutton").on('click', function (event) {
                      var selectedrowindex = $("#jqxgrid").jqxGrid('getselectedrowindex');
                      var row = $("#jqxgrid").jqxGrid('getrowdata', selectedrowindex);
                      window.location.href = "Details.aspx?id=" + row.id;

                  });

                  // create new row.
                  $("#addrowbutton").on('click', function () {
                      window.location.href = "Add.aspx";
                  });

                  // delete row.
                  $("#deleterowbutton").bind('click', function (event) {
                      if (confirm("Etes vous sûr de vouloir de supprimer ce constat?")) {

                          var selectedrowindex = $("#jqxgrid").jqxGrid('getselectedrowindex');
                          var row = $("#jqxgrid").jqxGrid('getrowdata', selectedrowindex);
                          $.ajax({
                              type: "POST",
                              url: "Liste.aspx/DeleteAudit",
                              data: '{id: ' + row.id + '}',
                              contentType: "application/json; charset=utf-8",
                              datatype: "jsondata",
                              success: function (response) {
                                  /*refresh the grid*/
                                  window.location.reload()
                              }
                          });
                      }
                      return false;
                  });
}

它运作正常。

问题是当下面的条件为真且最后两个按钮被隐藏时,第一个按钮不再起作用:

protected void Page_Load(object sender, EventArgs e)
{
    if (Roles.IsUserInRole(HttpContext.Current.User.Identity.Name, "consult"))
    {
        addrowbutton.Visible = false;
        deleterowbutton.Visible = false;   
    }

}

任何想法??

0 个答案:

没有答案