jqgrid addrowdata problem

前端 未结 1 402
醉话见心
醉话见心 2021-01-21 06:34

I have a problem with adding a new empty row in a jqgrid.

My colmodel is :

colModel: [{ name: \'recid\', index: \'testid\', hidden: true, editable: true,         


        
相关标签:
1条回答
  • 2021-01-21 07:14

    try instead of that

    var newRowData = [{ "recid": rowid, "JobTask.Id": "@(Model.id)", "InvolvedParty.Id": "", "InvolvedParty.Lastname": "", "deletefield": ""}];
    

    doing :

    var newRowData = { "recid": rowid, "JobTask.Id": "@(Model.id)", "InvolvedParty.Id": "", "InvolvedParty.Lastname": "", "deletefield": ""};
    
    • if this won't work , make sure that added rows for sure have different ids

    • you can also try reloading after adding new row by trigger(“reloadGrid”)

    hope that will help i have no more ideas

    EDIT :

    ok i now what was wrong

    from jqgrid wiki :

    ... This method can insert multiple rows at once. In this case the data parameter should be array defined as [{name1:value1,name2: value2…}, {name1:value1,name2: value2…} ] and the first option rowid should contain the name from data object which should act as id of the row. It is not necessary that the name of the rowid in this case should be a part from colModel.

    that meens you should be able also to use [] like that :

    var newRowData = [{ "recid": rowid, "JobTask.Id": "@(Model.id)", "InvolvedParty.Id": "", "InvolvedParty.Lastname": "", "deletefield": ""}];
    
    $("#grid_id").addRowData("recid", newRowData);
    
    0 讨论(0)
提交回复
热议问题