当网格是编辑/添加模式时,如何将列的值获取到其他列

时间:2016-06-09 05:25:28

标签: jquery mysql ajax jqgrid

我在网格中遇到问题,我想做一些像column A这样的操作,column B这两个都是字符串值的下拉列表,我想在{{two中使用这个column C值1}}使用data(single value)从datebase中获取Query。你能告诉我如何获得two column valuesthird column以及如何在第三列中执行操作以使用两个列值从数据库中获取数据。请提前帮助我。

这是我的代码

  <div class='wrapper' align="center">
    <table id="jqGrid" ></table> 
    <div id="jqGridPager" ></div>   
  </div> 

<script>
        $('#appweek').on('change', function (event) { alert('Applicable Date Changed'); $('#jqGrid').trigger("reloadGrid"); });

        function myelem (value, options) {
          var el = document.createElement("input");
          el.type="text";
          el.value = $("#appweek option:selected" ).text();
          return el;
        }

        function myvalue(elem, operation, value) {
            if(operation === 'get') {
               return $(elem).val();
            } else if(operation === 'set') {
               $('input',elem).val(value);
            }
        }

        $("#jqGrid").jqGrid({
            url:'server.php',
            editurl: 'add.php',
            datatype: "json",
            shrinkToFit: true,
            colNames:['REQUEST NO','Employee_Login','Applicable Date','Change_Type','New_Value','Existing_Value','Requestor NOTES','Status'],
            colModel:[
                {name:'ID', index:'ID',align:"center"},
                {name:'Employee_Login', index:'Employee_Login', align:"center",editable:true,editrules: { required: true},edittype:'select',editoptions:{dataUrl:'el.php'}},
                {name:'applicable_date', index:'applicable_date', align:"center",hidden:true,editable:true,editrules: {required: true},edittype:'custom', editoptions:{readonly: true,custom_element: myelem, custom_value:myvalue}},
                {name:'Change_Type', index:'Change_Type', align:"center",editable:true,editrules: { required: true},edittype:'select', editoptions: { value: "WeekNo:WeekNo; WeekBeginning:WeekBeginning; SITE:SITE; WFH:WFH; ManagerLogin:ManagerLogin; Lead:Lead; CostCenter:CostCenter; Business_Title:Business_Title; Function:Function; WorkGroup:WorkGroup; LoginTime:LoginTime; ROLE:ROLE; SecondarySkill:SecondarySkill; WeekOff:WeekOff;"}},
                {name:'New_Value', index:'New_Value', align:"center",editable:true,editrules: { required: true}},
                {name:'Existing_Value', index:'Existing_Value', align:"center",editable:true,editrules: { required: true},edittype:'select',editoptions:{dataUrl:'ex.php'}},
                {name:'Requestor_NOTES', index:'Requestor_NOTES', align:"center",editable:true,edittype:'textarea', editoptions: {rows:"2",cols:"10"}},
                {name:'Status', index:'Status', align:"center",editable:false},
            ],      
            rowNum:200,
            rowList:[400,300,200],
            pager: '#jqGridPager',
            sortorder: "asc",
            sortname:'id',
            viewrecords: true,
            height:'500',
            width:'1000',

        });

        jQuery("#jqGrid").jqGrid('navGrid',"#jqGridPager",{edit:false,del:false,search:false,add:false});
        jQuery("#jqGrid").jqGrid('inlineNav',"#jqGridPager");

    </script>

0 个答案:

没有答案