function $(id){ return document.getElementById(id); } function InitGridEdit(){ var jsonObj = null; if(tempJson != ""){ // alert(tempJson); jsonObj = eval('(' + tempJson + ')'); $("h_gridcache").value = JSON.stringify(jsonObj); $("h_origcache").value = JSON.stringify(jsonObj); for(var i=0;i字段标题 不能为空 " return; } name = $("txt_name").value.trim(); if(name == ""){ $("dvNameError").innerHTML = "
SQL字段值 不能为空
" return; } $("txt_sort").value = name; align = $("sel_align").value.trim(); index = $("dvNo").innerHTML.trim() == ""?0: parseInt($("dvNo").innerHTML.trim()); if(index == 0){ index = jsonObj.items.length; $("dvNo").innerHTML = index; } type = $("sel_type").value.trim(); width = $("txt_width").value.trim() == ""?0: parseInt($("txt_width").value.trim()); if(width == 0){ $("dvWidthError").innerHTML = "
显示宽度 不能为空
" return; } sort = $("txt_sort").value.trim(); remark = ""; gtype = $("sel_gtype").value.trim(); var newObj = jsonObj.items; newObj = {title:title,name:name,index:index,type:type,width:width,sort:sort,remark:remark,gtype:gtype,align:align}; jsonObj.items.push(newObj); tempJson = JSON.stringify(jsonObj); if($("h_name").value != name){ $("h_name").value = name; } $("h_gridcache").value = JSON.stringify(jsonObj); InitGridEdit(); var addObj = $("sel_added"); addObj.scrollHeight; for(var k=0;kSQL字段值 不能为空 " return; } } } } } function addItem(){ var jsonObj = null; if(tempJson != ""){ jsonObj = eval('(' + tempJson + ')'); if(jsonObj.items.length > 0){ $("dvNo").innerHTML = jsonObj.items.length; } } $("h_name").value = ""; $("txt_title").value = ""; $("txt_width").value = ""; $("txt_name").value = ""; $("ck_hidden").checked = false; $("sel_align").value = ""; $("sel_gtype").value = "ro"; $("sel_added").value = ""; } String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); } function checkVisible(obj){ if(obj.checked){ $("txt_width").value = "0"; $("txt_width").disabled = true; }else{ $("txt_width").disabled = false; } } function itemUp(){ var addObj = $("sel_added"); var selectedArg = new Array(); var jsonObj = null; if(tempJson != ""){ jsonObj = eval('(' + tempJson + ')'); } for(var i=0;i 0){ selectedArg.push(addObj.options[i].value); for(var j=iExistCount;j=0;j--){ if(jsonObj.items[i].name == selectedArg[j]){ addObj.options[addObj.options.length-1].selected = true; //addObj.scrollHeight; break; } } } } $("h_gridcache").value = JSON.stringify(jsonObj); } function itemDown(){ } function reInitJs(){ if(document.getElementById("orig"+$("h_templatename").value) == null){ var url = "../UserSettings/UserGridSource/Orig"+$("h_templatename").value+"Grid.js?uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); var jsVal = loader.xmlDoc.responseText; if(jsVal.indexOf("headerArgs") >=0 ){ var oHead = document.getElementsByTagName('head').item(0); var oScript = document.createElement( "script" ); oScript.language = "javascript"; oScript.type = "text/javascript"; oScript.id = "orig"+$("h_templatename").value; oScript.defer = true; oScript.text = jsVal; oHead.appendChild(oScript); } } // if(document.getElementById("defaultsource") == null){ // var url = "../js/DefaultSource.js?uid="+newGuid(); // var loader = dhtmlxAjax.getSync(url); // var jsVal = loader.xmlDoc.responseText; // // var oHead = document.getElementsByTagName('head').item(0); // var oScript = document.createElement( "script" ); // oScript.language = "javascript"; // oScript.type = "text/javascript"; // oScript.id = "defaultsource"; // oScript.defer = true; // oScript.text = jsVal; // oHead.appendChild(oScript); // } if(document.getElementById($("h_templatename").value) == null){ var url = "../UserSettings/UserGridSource/" + $("h_userid").value + "grid"+$("h_templatename").value+".js?uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); var jsVal = loader.xmlDoc.responseText; if(jsVal.indexOf("newHeaderArgs") >= 0){ var oHead = document.getElementsByTagName('head').item(0); var oScript = document.createElement( "script" ); oScript.language = "javascript"; oScript.type = "text/javascript"; oScript.id = $("h_templatename").value; oScript.defer = true; oScript.text = jsVal; oHead.appendChild(oScript); } } // var templateName = "template"+$("h_templatename").value; // if(document.getElementById(templateName) == null){ // var url = "../UserSettings/UserGridSource/"+templateName+"Grid.js?uid="+newGuid(); // // var loader = dhtmlxAjax.getSync(url); // var jsVal = loader.xmlDoc.responseText; // // alert(jsVal); // //if(jsVal.indexOf("tempJson") >= 0){ // var oHead = document.getElementsByTagName('head').item(0); // var oScript = document.createElement( "script" ); // oScript.language = "javascript"; // oScript.type = "text/javascript"; // oScript.id = templateName; // oScript.defer = true; // oScript.charset = "gb2312"; // oScript.text = jsVal; // oHead.appendChild(oScript); // //} // } } function newGuid(){ var guid = ""; for (var i = 1; i <= 32; i++){ var n = Math.floor(Math.random()*16.0).toString(16); guid += n; if((i==8)||(i==12)||(i==16)||(i==20)) guid += "-"; } return guid.toUpperCase(); }