• 存储表常用方法积累


    存储表常用方法积累

    1、修改创建存储表时的列信息

    1. dom.bind( "OnDataSetEvent", function (e,para){
    2.         if (para.IDataSetEvent.mType==="DSEVENT_OPEN" ){
    3.             var arrayModel = para.IDataSetEvent.mExtParams.newColModel.slice();
    4.             var arrayName = para.IDataSetEvent.mExtParams.newColModel.slice();
    5.             var i = 0;
    6.             var j = 0;
    7.             $.each(arrayModel, function (k,v){
    8.                 if (v.name=="F_SCHEMA_FMC" ){
    9.                     i = k;
    10.                 }
    11.                 if (v.name=="F_SCHEMA" ){
    12.                     v.width = "80" ;
    13.                     j = k;
    14.                 }
    15.             });
    16.             para.IDataSetEvent.mExtParams.newColModel[i] = arrayModel[j];
    17.             para.IDataSetEvent.mExtParams.newColModel[j] = arrayModel[i];
    18.             para.IDataSetEvent.mExtParams.newColNames[i] = arrayName[j];
    19.             para.IDataSetEvent.mExtParams.newColNames[j] = arrayName[i];
    20.         }
    21. });

    2、加载完成事件

         

    1. dom.bind("panGrid_loadCompleteTrigger",function(){
              dom.jqGrid("hideCol",["F_PKEY"]);
              dom.setLabel("F_SCHEMA_FMC","方案名称");
              dom.setLabel("F_SCHEMA","方案编号");
              dom.jqGrid("showCol",["F_SCHEMA"]);
         });

    3、新增行

         

    1. dom.panJqStore("addNewRow",{"newData":{"F_SCHEMA":ysbh}});
    2. doms.find("table[storeid='YL_GCQRD_MX']").panJqStore("addNewRow",{"newData":{}});    //子凭据新增一行

    4、删除行

         

    1. dom.panJqStore("deleteRow");

    5、保存

         

    1. dom.panJqStore("submit");

    6、刷新

         

    1. dom.panJqStore("initpaging");
    2.      dom.panJqStore("reLoadData");

    7、设置行的某一列数据

    1. cdoms.panJqStore("setRowData", { rowid : rowid,rowData : obj});

     

    8、隐藏列

               

    1. dom.setGridParam().hideCol(col).trigger("reloadGrid"); //jqgrid原生
    2. dom.jqGrid("hideCol",col);//panJqStore封装  col为数组

    9设置列不可编辑

     

    1. $("#grid9").jqGrid("removeColEditable",[数组]);//设置列不可编辑

    10、设置列可编辑

    1. cdoms.jqGrid("setColEditable",cols);

    10、获取某一列数据

       

    1. $("#grid9").jqGrid('getCol','列名',false);

    11、监听input事件 获取选中行数据

    1. //监听input事件
    2. function listenpz(gridid) {
    3. var doms = $("#" + gridid);
    4. doms.bind("input", function(e, para) {
    5. var rowid=para.rowid;
    6. var rowdata = doms.jqGrid("getRowData", rowid);
    7. });
    8. }

     

    12、输入框模糊搜索

    1. function sprinputselect() {
    2. $("#spr").panTextInputSelect({
    3. changed: function(v, cb) {
    4. if (v !== "") {
    5. var senddata1 = {
    6. "service": "BIZDctService",
    7. "method": "queryDCTPageRowEx",
    8. "DCT_ID": "SSF_USERS", //字典表
    9. "DCT_PARENT_ID": "#ROOT",
    10. "DCT_PARENT_LEVEL": "0",
    11. "SHOW_ALL_CHILDREN": "1",
    12. //名称和id
    13. "SQL_FILTER_WHERE": "ZD.USR_USRID like '" + v + "%' or ZD.USR_CAPTION like '%" + v + "%'"
    14. };
    15. var xx = $.ajax({
    16. url: "commAction.do",
    17. data: {
    18. jsondata: $.toJSON(senddata1)
    19. },
    20. type: "POST",
    21. dataType: "json",
    22. async: true,
    23. success: function(data) {
    24. var array = [];
    25. $.each(data.DCT_ROWSET.ROWS, function(k, v) {
    26. var obj = {};
    27. obj.icon = "TIS-test-icon";
    28. obj.bh = v.USR_USRID;
    29. obj.mc = v.USR_CAPTION + "(" + v.USR_USRID + ")";
    30. obj.hpid = v.USR_USRID;
    31. array.push(obj);
    32. });
    33. cb(array);
    34. }
    35. });
    36. return xx;
    37. } else {
    38. var array = [];
    39. cb(array);
    40. $("#spr").data("userInfo", {
    41. "userid": "",
    42. "usermc": ""
    43. });
    44. return null;
    45. }
    46. },
    47. selected: function(data) { //点击事件
    48. $("#spr").data("userInfo", {
    49. "userid": data.bh,
    50. "usermc": data.mc
    51. });
    52. searchs();
    53. return data.mc;
    54. },
    55. "width": 160,
    56. "max_height": 158
    57. });
    58. }
    59. 查询:
    60. var sprid = "";
    61. var spr = $("#spr");
    62. if (spr.val() != "") {
    63. sprid = spr.data("userInfo").userid;
    64. stoobj.F_SPR = "%%" + sprid;
    65. }

    13、设置多选框不可编辑(用jqgrid原生)

    1. dom.jqGrid("removeColEditable","F_TRS_OK");

    14、存储表公司选择明细级

      Swing  sto  公司字段  ShowFormat  ACT:0012

     

     

     


    15、进度条,参考资产卡片同步

    1. <div class="pbarDiv" style="display:none">
    2.         <!-- 进度条开始 -->
    3.         <div id="progress_bar" class="ui-progress-bar">
    4.             <div class="ui-progress"></div>
    5.             <div class="ui-label">
    6.                 <span class="value">同步中...</span>
    7.             </div>
    8.         </div>
    9.         <!-- 进度条结束 -->
    10. </div>
    11. 默认隐藏 执行方法是设为显示  执行后隐藏

    16、获取grid改变过的数据

        

    1.  dom.panGrid("creatFormatData");
    2.  var rowdatas = dom.panGrid("getChangedData");
    3. 根据rowdata 里的RS值的第一个数字可以判断该行数据是新增 删除 修改 状态
    4. 新增是“1 修改是“0

    17、jqgrid判断两行直接是否有重复数据(科目与物料对照)

     

    1.   dom.jqGrid("removeEditState"); //移除单元格的编辑状态
    var colVal = dom.jqGrid('getRowData');
    if (colVal.length > 0) {
    var n = {};
    n[colVal[0]["F_KMBH"] + "_" + colVal[0]["F_FKWL"]] = true; //hash表赋默认值,如:{"0001":true}
    var repeat = "0";
    for (var i = 1; i < colVal.length; i++) {
    if (n[colVal[i]["F_KMBH"] + "_" + colVal[i]["F_FKWL"]]) { //如果hash表中没有当前项
    repeat = "1";
    break; //跳出for循环
    } else {
    n[colVal[i]["F_KMBH"] + "_" + colVal[i]["F_FKWL"]] = true;
    }
    }
    if (repeat == "1") {
    tipAlert("消息提示", "同一个物料编号不能有重复科目!", "确认", 0);
    return false;
    }
    $("#grid9").panJqStore("submit");;
    }

     

    18、设置某一行选中状态

    1. $('#timeGrid tr').eq(3).find('td').eq(1).click();
    19、导出excel
    1. function dcexcel(){
    2. var excelname = "";
    3. var djlxid = djlxselect.panSelect("getValue");//单据类型
    4. if(djlxid=="0089"){
    5. name="其他入库单"
    6. }
    7. if(djlxid=="0090"){
    8. name="其他出库单"
    9. }
    10. var coVal = $("#grid9").jqGrid('getCol','F_SSDW_FMC',false);
    11. if(coVal.length){
    12. excelname = "信息补录(单位:"+coVal[0]+"、单据类型:"+name+")";
    13. }else{
    14. excelname = "信息补录(单据类型:"+name+")";
    15. }
    16. var para = {"pdivid":"contgrid","tableid":"grid9","excelname":excelname};
    17. var pdivid = para.pdivid;//包含grid的div id
    18. var tableid = para.tableid;//创建tablegrid的id
    19. var excelname = para.excelname;//要导出的excel的名称
    20. var allobj = {};
    21. var headobj = {};
    22. var tablehead = $("#"+pdivid).find("table").eq(0);
    23. var trarrayh = [];
    24. var tdobjh = {};
    25. tdobjh.rowspan = "1";
    26. tdobjh.colspan = $("#"+tableid).find("tr").eq(0).find("td:visible").length;
    27. tdobjh.value = excelname;
    28. tdobjh.align = "2";
    29. tdobjh.type = "1";
    30. tdobjh.format = "";
    31. tdobjh.fontsize = "15";
    32. tdobjh.fontname = "微软雅黑";
    33. trarrayh.push(tdobjh);
    34. headobj["tr"] = trarrayh;
    35. $.each(tablehead.find("tr"),function(k,v){
    36. var trarray = [];
    37. var index = 0;
    38. if(tablehead.find("tr").length===1){
    39. index = -1;
    40. }
    41. if(k!==index){
    42. $.each($(v).find("th"),function(a,b){
    43. if($(b).is(":visible")){
    44. var tdobj = {};
    45. tdobj.rowspan = $(b).attr("rowspan")||"1";
    46. tdobj.colspan = $(b).attr("colspan")||"1";
    47. if($(b).find("div").length>0){
    48. tdobj.value = $(b).find("div").text();
    49. }else{
    50. tdobj.value = $(b).text();
    51. }
    52. tdobj.align = "2";
    53. tdobj.type = "1";
    54. tdobj.format = "";
    55. trarray.push(tdobj);
    56. }
    57. });
    58. headobj["tr"+k] = trarray;
    59. }
    60. });
    61. var rowsobj = {};
    62. var tablerows = $("#"+tableid);
    63. $.each(tablerows.find("tr"),function(k,v){
    64. var trarrayrows = [];
    65. if(k!==0){
    66. $.each($(v).find("td"),function(a,b){
    67. if($(b).is(":visible")){
    68. var tdobj = {};
    69. tdobj.rowspan = "1";
    70. tdobj.colspan = "1";
    71. if($(b).find("input").length>0){
    72. tdobj.value = $(b).find("input").val();
    73. }else{
    74. tdobj.value = $("#"+tableid).jqGrid("getCell",$(v).attr("id"),a);
    75. }
    76. var newcolmodel = $("#"+tableid).jqGrid("getGridParam","colModel");
    77. var zd = $(b).attr("aria-describedby").replace(tableid+"_","");
    78. $.each(newcolmodel,function(c,d){
    79. if(d.name===zd){
    80. var formatter = d.formatter||"";
    81. var format = "";
    82. var type = "1";//字符型
    83. if(formatter==="number"){
    84. format = "###,##0.00"||"";
    85. if(tdobj.value===""){
    86. tdobj.value = "0";
    87. }
    88. if(parseFloat(tdobj.value)===0){
    89. if(format!==""){
    90. format = "0.00";
    91. }
    92. }
    93. type = "0";
    94. }
    95. tdobj.type = type;
    96. tdobj.format = format;
    97. return false;
    98. }
    99. });
    100. //tdobj.value = $(b).text();
    101. var talign = $(b).css("text-align");
    102. if(talign==="left"){
    103. tdobj.align = "1";
    104. }
    105. if(talign==="center"){
    106. tdobj.align = "2";
    107. }
    108. if(talign==="right"){
    109. tdobj.align = "3";
    110. }
    111. trarrayrows.push(tdobj);
    112. }
    113. });
    114. rowsobj["tr"+k] = trarrayrows;
    115. }
    116. });
    117. allobj.head = headobj;
    118. allobj.body = rowsobj;
    119. var excelobj = {};
    120. excelobj[excelname] = allobj;
    121. var exportexcel = {};
    122. exportexcel.F_KEY = excelobj;
    123. exportexcel.F_VALUE = excelname+".xlsx";
    124. var formhtml = "<form id='expexcel' name='excels' action='"+sys_ctx+"/exportExcel.do' method='POST'>"
    125. +"<input id='exportex' name='exportex' type='hidden'>"
    126. +"</form>";
    127. $("body").append(formhtml);
    128. $("#exportex").val($.toJSON(exportexcel));
    129. var form1 = window.document.getElementById("expexcel");//获取form1对象
    130. form1.submit();
    131. }





    一切为了梦想!
  • 相关阅读:
    C# .NET 微信开发-------当微信服务器推送消息时如何接收处理
    P1991 无线通讯网[MST]
    P2330 [SCOI2005]繁忙的都市【MST】
    P1546 最短网络 Agri-Net【MST】
    P3225 [HNOI2012]矿场搭建【割点 + 求点双 + 简单组合数】
    P3119 [USACO15JAN]Grass Cownoisseur G [ Tarjan + 缩点 + 拓扑序 + dp + 最长路] [好题]
    P2746 [USACO5.3]校园网Network of Schools [tarjan缩点]
    P1196 [NOI2002]银河英雄传说 【带权并查集】
    P1197 [JSOI2008]星球大战 [删边求连通块个数]
    GPLT L2-004 这是二叉搜索树吗?
  • 原文地址:https://www.cnblogs.com/wenqd/p/0e44fdbcc9bc1c20c028e65c4ea0a75e.html
Copyright © 2020-2023  润新知