我是ExtJS的新手,我正在尝试实现一个组合框和“保存”按钮,该按钮将为网格中选择的所有记录保存“ boxStatus”(有一个用于选择记录的复选框框和一个组合框)状态)。我已经尝试过以下ajax调用:

saveBulkBoxComments : function(){
    var formObj = this.getPositionPanel().getForm();
    var fieldValues = formObj.getFieldValues();

        Ext.Ajax.request({
        url: SAVE_BULK_BOX_COMMENTS_URL,
        method: 'POST',
        params: {
            positionDate: this.parentRecordData.data.positionDate,
            groupIds: this.parentRecordData.data.groupId,
            boxStatus: fieldValues.boxStatus,
            csrComment: fieldValues.csrComment
        },
        success : function(response) {
                //how do I update box status for all records selected?
                this.loadPositions();
        },
        scope: this
        });
}


这是Java:

return getReturnValue(new Runnable() {
        public void run() {
            String groupIdList[] = groupIds.split(",");
            String user = mercuryUserScreenNameGetter.getValue(request);
            Date date = Utils.parseDate(positionDate, DATE_FORMAT);
            Stream.of(groupIdList)
                .forEach(groupId ->
                positionsDataMediator.addBoxAnnotation(date,user, groupId,   csrComment, boxStatus));
            }
});


我不太确定如何为所有选定记录过帐所有boxStatus。当我点击“保存”时,是否需要编写一种遍历所有记录的方法?这似乎是错误的...谢谢您的帮助。

最佳答案

经过一番摆弄之后,我开始工作了。诀窍是遍历每个选定记录的每个groupID ...这样,我就可以一次更新每个记录的boxStatus:

saveBulkBoxComments : function(){


         grid = this.getPositionPanel();
         var store = grid.getStore();


         formObj = this.getBoxCommentsFormPanel().getForm();
         var fieldValues = formObj.getFieldValues();

         var value='';


         selectedRecords = grid.getSelectionModel().getSelection();


         Ext.each(selectedRecords, function(item) {
             value +=item.get('groupId') +',';
             }
         );

         Ext.Ajax.request({
             url: SAVE_BULK_BOX_COMMENTS_URL,
             method: 'POST',
             params: {
                 groupIds :value,
                 positionDate: this.parentRecordData.data.positionDate,
                 boxStatus: fieldValues.boxStatus,
                 csrComment: fieldValues.csrComment

             },

             success: function(result, action, response) {
                 var jsonData = Ext.decode(result.responseText);


                 var jsonRecords = jsonData.records;

                 Ext.getCmp('boxCommentsWindow').close();
                 this.loadPositions();

                },

                scope: this
                });
             }


});

10-07 23:54