Form - 列表表格 

通过JS添加行

$(function() { //注意 $(function) 的执行顺序,在表单中添加行的自定义html要放在 List Grid 的后面
        var args1={  //id为List Grid中设置的唯一列的值,result内是完整的数据
            id:"Anti-LILRB1 抗体[EPR21007]Anti-LILRB1 antibody [EPR21007]10ul瓶",
            result:'{"uniqueCL":"Anti-LILRB1 抗体[EPR21007]Anti-LILRB1 antibody [EPR21007]10ul瓶","brandName":"Abcam","reagentName":"Anti-LILRB1 抗体[EPR21007]/Anti-LILRB1 antibody [EPR21007]","catNo":"ab229186","cas":"","specification":"","package":"10ul瓶","prodSupplierPrice":"634.20","amount":"1","inNum":"2","supplierPrice":"634.20","status":"","ydFlag":"Y","orderline_id":"01695861-df8a-42ff-b4ba-cfc062164c24","order_id":"0fe902fc-d142-4217-961b-6e80dc956907","stockType":"出库"}'
        };
        $("div[name='field4']").listgrid("addRow", args1); //'field4'是List Grid的ID,
    });

Form - 电子表格

通过JS修改保存时的表格数据

function setSheetValue(fieldId,fieldValue,line){ //fieldId列的id, fieldValue 修改的值  line:修改的行数,从0开始
            let jsonTextArea = $("div[name='deliverLine']").find('.jsonDataContainer');
            let jsonArr = jsonTextArea.val();
            if(undefined == jsonArr || jsonArr == ''){
                return;
            }
            jsonArr = JSON.parse(jsonArr);
            if(line>=jsonArr.length){
                return;
            }
            let jsonObj = jsonArr[line];
            jsonObj[fieldId] = fieldValue;
            jsonTextArea.val(JSON.stringify(jsonArr))
        }
  • No labels