1

i've been using jqgrid widely (and successfully) on my asp.net web application.

Is it possible to invert column order in form editing? ie: colmodel shows

COLUMN A COLUMN B COLUMN C

I'd like to show something similar to:

COLUMN A COLUMN C COLUMN B

when user click the edit icon and enter the form editing dialog.

EDIT: i've read the remapColumns function exist (check it out). Is it possible to use it on form editing?

Community
  • 1
  • 1
frabiacca
  • 1,402
  • 2
  • 16
  • 32

1 Answers1

1

You can change the order of the column order with respect of the following simple code

beforeShowForm: function ($form) {
    var i, l, $tinfo = $form.find('tr.tinfo'),
        $trFormData = $form.find('tr.FormData');
    for (i = 1, l = $trFormData.length; i < l; i++) {
        $tinfo.after($trFormData[i]);
    }
}

see the demo. As the result you will get

enter image description here

instead of default form

enter image description here

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • oleg, i'm sorry, but this is not what I'm looking for. It seems to me that you just inverted column order; I'd like to recreate form field order instead. You wrote me to use recreateForm:true yesterday, i've been searching for an example since that instant :( – frabiacca Feb 11 '12 at 09:22
  • @frabiacca: You asked me one comment my about the usage of `remapColumns`. If you change the order of columns it's important to use [recreateForm:true](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing#properties) (see [here](http://stackoverflow.com/a/6971820/315935) an example) to have the current order of columns. Your current question is "jqgrid form editing: invert column order". It's not depend from the usage of `columnChooser`, `reorderColumn` and so on. If there are some other additional steps where you need another order of the fields in the form dialog - please describe – Oleg Feb 11 '12 at 12:42
  • hey oleg, i find that formoptions contains rowpos attribute, that is exactly what i was looking for ;) – frabiacca Feb 11 '12 at 14:37
  • @frabiacca: OK! I just still not full understand your question. If you really have *tree* columns like COLUMN A COLUMN B COLUMN C and you want *to specify* the position of *one column* you can good use `rowpos`. So if you need *to specify* the row where the field for the column will be placed the `rowpos` is the best way, but you can't use the option *to invert* the column order because if you would modify `colModel` and insert one more column you will have to modify **all** `rowpos` values all columns. So it was just misunderstanding of your requirements. – Oleg Feb 11 '12 at 15:06
  • @frabiacca: In any way it's fine that your problem is solved! – Oleg Feb 11 '12 at 15:07