Jqgrid getting value that we entered and change the editable attribute of a form

后端 未结 1 373
有刺的猬
有刺的猬 2021-01-17 03:38

excuse me guys, but i\'m having these two problems. i hope you guys can help me with this.

here is part of my code

jQuery(\"#VWWMODULE\").jqGrid(
{
u         


        
1条回答
  •  隐瞒了意图╮
    2021-01-17 04:14

    I suppose, that your main problem now is only changing of id in the grid after editing.

    First of all it's extremely important that you write in all your questions: which editing mode you use and whether you use loadonce: true if you load data from the server (datatype: "json").

    Only indirectly one can suppose that you use form editing mode because you use formoptions options in colModel. Form editing has reloadAfterSubmit option (see the documentation) which default value is true. It means that jqGrid reload the whole content of the grid after successful submitting of editing of one row. The setting simplify interface to the server. If you use the default option then you will have no problem with id editing and no problem with correct sorting of data after editing.

    If you do decide to use reloadAfterSubmit option then you have to do additional work. The server should response with new value of id. The id will be typically generated by database in case of holding data in the database. You have to implement afterSubmit callback which should decode new id from the server response and return it.

    If you do use inline editing and need to change id then I would forward you to the answer. aftersavefunc callback from the example contains the code which modify id.

    UPDATED: I'v seen here that you asked the same question in the trirand forum. I wanted shortly comment one point from the Tony's answer.

    Every Add or Edit form contains table with the data (another table contains buttons which one see at the bottom of the form). The first two and the last one rows of the table are mostly hidden and contains (or can contains) helpful information:

    enter image description here

    For example the last row contains input field with id="id_g". The row exist event you don't have the column id (like in your grid). So $("#id_g").val() contains the rowid of the editing row. Add dialog contains the string "_empty" on the place.

    UPDATED 2: If you need to display id field in Add and Edit form but make it readonly you need just use readonly: 'readonly' property for id column (see here). The next problem: you should use recreateForm: true property for both Add and Edit forms.

    I don't recommend you to use reloadAfterSubmit: true, but if you really need to use the option you should returns from the server (from savewmodule.php) the id of new added row and you have to use afterSubmit callback to get the new id from the server response and return it in documented way (return [true, "", new_id];). Additionally you have to set content of "id" column of grid after saving of row. You should modify id property of postdata parameter of afterSubmit callback.

    0 讨论(0)
提交回复
热议问题