Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inline Row delete not setting custom request header #491

Open
boulepick opened this issue Apr 27, 2020 · 0 comments
Open

inline Row delete not setting custom request header #491

boulepick opened this issue Apr 27, 2020 · 0 comments

Comments

@boulepick
Copy link

Good day all,

i seem to be running into a minor issue that is causing a lot of headeach to me.
i'm using free-jqgrid 4.15.5 => https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.15.5/jquery.jqgrid.min.js

So my setup is as follow

  $.extend($.jgrid.defaults, {
    ajaxRowOptions: {
      beforeSend(jqXHR) {
        jqXHR.setRequestHeader('token', Token);
      },
    },
  });

and then in my grid setup i have

  const jqGridOptions = {
    mtype: 'POST',
    datatype: 'JSON',
    prmNames: { nd: null }, //  to enable browser caching of the edit data
    page: 1,
    pgbuttons: false, // disable page control like next, back button
    pgtext: null,
    regional: lang,
    guiStyle: 'bootstrap4',
    iconSet: 'fontAwesomeLight',
    loadonce: true,
    viewrecords: true,
    height: 'auto',
    rowNum: 20,
    sortorder: 'asc',
    rownumbers: true, // show row numbers
    rownumWidth: 35, // the width of the row numbers columns
    gridview: true,
    autowidth: true,
  };

  const certGridOptions = $.extend(true, {}, jqGridOptions, {
    url: URLGet,
    editurl: URLGridUpdate,
    pager: '#GridPager',
    colNames: certColNames,
    loadBeforeSend(jqXHR) {
      jqXHR.setRequestHeader('token', Token);
    },
    colModel: [
      {
        name: 'id',
        key: true,
        editable: false,
        viewable: false,
        editrules: {
          edithidden: true,
        },
        hidden: true,
        width: 80,
        align: 'left',
      },
      {
        name: 'name',
        // key: true,
        width: 400,
        editable: true,
        edittype: 'select',
        editrules: {
          required: true,
        },
        editoptions: {
          dataUrl: URLGet,
          cacheUrlData: true,
          dataInit(elem) {
            $(elem).addClass('inline-edit-cell form-control input-xs');
          },
        },
      },
      {
        name: 'image',
        search: false,
        editable: false,
        edittype: 'file',
        formatter: imagerenderer,
        align: 'center',
      },
      {
        name: 'verified',
        width: 80,
        align: 'center',
        sorttype: 'number',
        editable: false,
        edittype: 'checkbox',
        editoptions: {
          value: 'True:False',
        },
        formatter: 'checkbox',
        formatoptions: {
          disabled: true,
        },
      },
    ],
    // eslint-disable-next-line object-shorthand
    onSelectRow: function (rowid, status, e) {
      const $self = $(this);
      const $target = $(e.target);
      const p = $self.jqGrid('getGridParam');
      const rowData = $self.jqGrid('getLocalRow', rowid);
      const $td = $target.closest('tr.jqgrow>td');
      const iCol = $td.length > 0 ? $td[0].cellIndex : -1;
      const cmName = iCol >= 0 ? p.colModel[iCol].name : '';

      if (cmName === 'image') {
        if ($target.hasClass('addImgLink')) {
          console.log('need to add image');
        }
      }
    },
  });

  // ============ init grid
  $grid
    .jqGrid(certGridOptions)
    .navGrid(
      '#GridPager', {
        edit: false,
        add: false,
        del: true,
        refresh: true,
        view: false,
        search: false,
      },
      /* edit parameters */
      {},
      /* add parameters */
      {},
      // del parameters
      {
        onclickSubmit(options, delId) {
        // get the vale from 'id' (label: 'userID') column
        // and extend the postdata with name property
          return {
            ID: $(this).jqGrid('getCell', delId, 'id'),
          };
        },
        reloadAfterSubmit: true,
      },
    )
    .inlineNav('#GridPager', {
      edit: false,
      add: true,
      del: true,
      cancel: true,
      editParams: { keys: true },
      addParams: { keys: true },
    });

so for adds and edits this is working fine, the token is sent to the server in the request headers fine and i do not get errors, however when deleting a row, it does not send the token and from my google research i do not see where i can set this option for the Delete events. Is this a bug or am i doing something wrong here.

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant