|
|
|
|
|
|
|
|
|
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<jsonObj.items.length;i++){
|
|
|
|
|
if(jsonObj.items[i].pk == 0){
|
|
|
|
|
var newOption = new Option(jsonObj.items[i].title,jsonObj.items[i].name);
|
|
|
|
|
$("sel_added").options.add(newOption);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkItem(itemName){
|
|
|
|
|
if(tempJson != ""){
|
|
|
|
|
jsonObj = eval('(' + tempJson + ')');
|
|
|
|
|
|
|
|
|
|
for(var i=0;i<jsonObj.items.length;i++){
|
|
|
|
|
if(jsonObj.items[i].name == itemName){
|
|
|
|
|
$("h_name").value = jsonObj.items[i].name;
|
|
|
|
|
$("txt_title").value = jsonObj.items[i].title;
|
|
|
|
|
$("txt_width").value = jsonObj.items[i].width;
|
|
|
|
|
$("txt_name").value = jsonObj.items[i].name;
|
|
|
|
|
|
|
|
|
|
if(jsonObj.items[i].width == 0){
|
|
|
|
|
$("ck_hidden").checked = false;
|
|
|
|
|
}else{
|
|
|
|
|
$("ck_hidden").checked = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("sel_align").value = jsonObj.items[i].align;
|
|
|
|
|
$("dvNo").innerHTML = jsonObj.items[i].index;
|
|
|
|
|
$("sel_gtype").value = jsonObj.items[i].gtype;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function dynamicSave(obj,opName){
|
|
|
|
|
var iCount = 0;
|
|
|
|
|
if(obj != null){
|
|
|
|
|
var jsonObj = null;
|
|
|
|
|
if(tempJson != ""){
|
|
|
|
|
jsonObj = eval('(' + tempJson + ')');
|
|
|
|
|
|
|
|
|
|
for(var i=0;i<jsonObj.items.length;i++){
|
|
|
|
|
if(jsonObj.items[i].name == $("h_name").value){
|
|
|
|
|
switch(opName){
|
|
|
|
|
case "title":
|
|
|
|
|
jsonObj.items[i].title = obj.value;
|
|
|
|
|
break;
|
|
|
|
|
case "name":
|
|
|
|
|
jsonObj.items[i].name = obj.value;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "width":
|
|
|
|
|
jsonObj.items[i].width = obj.value;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
tempJson = JSON.stringify(jsonObj);
|
|
|
|
|
|
|
|
|
|
$("h_gridcache").value = tempJson;
|
|
|
|
|
iCount++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(iCount == 0){
|
|
|
|
|
if($("txt_name").value.trim() != ""){
|
|
|
|
|
$("dvTitleError").innerHTML = "";
|
|
|
|
|
$("dvNameError").innerHTML = "";
|
|
|
|
|
$("dvWidthError").innerHTML = "";
|
|
|
|
|
var title = "";
|
|
|
|
|
var name = "";
|
|
|
|
|
var align = "";
|
|
|
|
|
var index = 0;
|
|
|
|
|
var type = "";
|
|
|
|
|
var width = 0;
|
|
|
|
|
var sort = "";
|
|
|
|
|
var remark = "";
|
|
|
|
|
var gtype = "";
|
|
|
|
|
|
|
|
|
|
title = $("txt_title").value.trim();
|
|
|
|
|
if(title == ""){
|
|
|
|
|
$("dvTitleError").innerHTML = "<div style=\"width:100%;color:#F00;\">字段标题 不能为空 </div>"
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
name = $("txt_name").value.trim();
|
|
|
|
|
if(name == ""){
|
|
|
|
|
$("dvNameError").innerHTML = "<div style=\"width:100%;color:#F00;\">SQL字段值 不能为空 </div>"
|
|
|
|
|
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 = "<div style=\"width:100%;color:#F00;\">显示宽度 不能为空 </div>"
|
|
|
|
|
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;k<addObj.options.length;k++){
|
|
|
|
|
if(addObj.options[k].value == name){
|
|
|
|
|
addObj.options[k].selected = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
$("dvNameError").innerHTML = "<div style=\"width:100%;color:#F00;\">SQL字段值 不能为空 </div>"
|
|
|
|
|
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<addObj.options.length;i++){
|
|
|
|
|
var iExistCount = 0;
|
|
|
|
|
if(addObj.options[i].selected){
|
|
|
|
|
if(i > 0){
|
|
|
|
|
selectedArg.push(addObj.options[i].value);
|
|
|
|
|
for(var j=iExistCount;j<jsonObj.items.length;j++){
|
|
|
|
|
if(iExistCount == 0){
|
|
|
|
|
if(addObj.options[i].value == jsonObj.items[j].name){
|
|
|
|
|
|
|
|
|
|
var title = jsonObj.items[j-1].title;
|
|
|
|
|
var name = jsonObj.items[j-1].name;
|
|
|
|
|
var align = jsonObj.items[j-1].align;;
|
|
|
|
|
//var index = jsonObj.items[j-1].index;
|
|
|
|
|
var type = jsonObj.items[j-1].type;
|
|
|
|
|
var width = jsonObj.items[j-1].width;
|
|
|
|
|
var sort = jsonObj.items[j-1].sort;
|
|
|
|
|
var remark = jsonObj.items[j-1].remark;
|
|
|
|
|
var gtype = jsonObj.items[j-1].gtype;
|
|
|
|
|
var pk = jsonObj.items[j-1].pk;
|
|
|
|
|
var close = jsonObj.items[j-1].close;
|
|
|
|
|
|
|
|
|
|
jsonObj.items[j-1].title = jsonObj.items[j].title;
|
|
|
|
|
jsonObj.items[j-1].name = jsonObj.items[j].name;
|
|
|
|
|
jsonObj.items[j-1].align = jsonObj.items[j].align;
|
|
|
|
|
//jsonObj.items[j-1].index = jsonObj.items[j].index;
|
|
|
|
|
jsonObj.items[j-1].type = jsonObj.items[j].type;
|
|
|
|
|
jsonObj.items[j-1].width = jsonObj.items[j].width;
|
|
|
|
|
jsonObj.items[j-1].sort = jsonObj.items[j].sort;
|
|
|
|
|
jsonObj.items[j-1].remark = jsonObj.items[j].remark;
|
|
|
|
|
jsonObj.items[j-1].gtype = jsonObj.items[j].gtype;
|
|
|
|
|
jsonObj.items[j-1].pk = jsonObj.items[j].pk;
|
|
|
|
|
jsonObj.items[j-1].close = jsonObj.items[j].close;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonObj.items[j].title = title;
|
|
|
|
|
jsonObj.items[j].name = name;
|
|
|
|
|
jsonObj.items[j].align = align;
|
|
|
|
|
//jsonObj.items[j].index = index;
|
|
|
|
|
jsonObj.items[j].type = type;
|
|
|
|
|
jsonObj.items[j].width = width;
|
|
|
|
|
jsonObj.items[j].sort = sort;
|
|
|
|
|
jsonObj.items[j].remark = remark;
|
|
|
|
|
jsonObj.items[j].gtype = gtype;
|
|
|
|
|
jsonObj.items[j].pk = pk;
|
|
|
|
|
jsonObj.items[j].close = close;
|
|
|
|
|
|
|
|
|
|
iExistCount = j;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addObj.options.length = 0;
|
|
|
|
|
for(var i=0;i<jsonObj.items.length;i++){
|
|
|
|
|
if(jsonObj.items[i].pk == 0){
|
|
|
|
|
var newOption = new Option(jsonObj.items[i].title,jsonObj.items[i].name);
|
|
|
|
|
addObj.options.add(newOption);
|
|
|
|
|
|
|
|
|
|
for(var j=selectedArg.length-1;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();
|
|
|
|
|
}
|