首頁 web前端 js教程 ext 代码生成器_YUI.Ext相关

ext 代码生成器_YUI.Ext相关

May 16, 2016 pm 06:48 PM
ext 程式碼產生器

本文件为:ext_editgrid_products.js,用来显示,编辑,删除products表的数据。

复制代码 代码如下:

var productsgrid;
var productsstore;
var productslimit = 25; //每页显示条数
var productsListPostUrl = "/management/procrequest/Proc_products.ashx?action=getlist";
var productsModifyPostUrl = "/management/procrequest/Proc_products.ashx?action=modify";
var productsDeletePostUrl = "/management/procrequest/Proc_products.ashx?action=del";
function initproductsGrid(containerid) {
Ext.menu.RangeMenu.prototype.icons = {
gt: 'images/greater_then.png',
lt: 'images/less_then.png',
eq: 'images/equals.png'
};
Ext.grid.filter.StringFilter.prototype.icon = 'images/find.png';
Ext.QuickTips.init();
function formatDate(value) {
return value ? value.dateFormat('M d, Y') : '';
};
var fm = Ext.form;
var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel([
sm,
{
id:'productId',
header: '产品编号',
dataIndex: 'productId',
sortable: true,
width:70,
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false
})
},
{
header: '产品名称',
dataIndex: 'productName',
sortable: true,
width:120,
editor: new fm.TextField({
allowBlank: false,
allowNegative: false
})
},
{
header: '金额',
dataIndex: 'money',
sortable: true,
width:120,
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false
})
},
{
header: '地址',
dataIndex: 'address',
sortable: true,
width:120,
editor: new fm.TextField({
allowBlank: false,
allowNegative: false
})
},
{
header: '电话',
dataIndex: 'tel',
sortable: true,
width:120,
editor: new fm.TextField({
allowBlank: false,
allowNegative: false
})
},
{
header: '备注',
dataIndex: 'remark',
sortable: false,
width:550,
editor: new fm.myHtmlEditor({
allowBlank: false,
allowNegative: false
})
},
{
header: '端口',
dataIndex: 'port',
sortable: true,
width:70,
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false
})
}
]);
cm.defaultSortable = true;
/*
var Plant = Ext.data.Record.create([
]);
*/
productsstore = new Ext.data.JsonStore({
root: 'list',
totalProperty: 'totalCount',
idProperty: 'productId',
remoteSort: true,
fields: [
{name: 'productId' },{name: 'productName' },{name: 'money' },{name: 'address' },{name: 'tel' },{name: 'remark' },{name: 'port' }
],
proxy: new Ext.data.ScriptTagProxy({
url: productsListPostUrl
})
});
productsstore.setDefaultSort('productId', 'desc');
var filters = new Ext.grid.GridFilters({
filters: [
{ type: 'string', dataIndex: 'productId' }, { type: 'string', dataIndex: 'productName' }, { type: 'string', dataIndex: 'money' }, { type: 'string', dataIndex: 'address' }, { type: 'string', dataIndex: 'tel' }, { type: 'string', dataIndex: 'remark' }, { type: 'string', dataIndex: 'port' }
    ]
});
var pagingBar = new Ext.PagingToolbar({
pageSize: productslimit,
store: productsstore,
displayInfo: true,
displayMsg: '第 {0} - {1} 条记录,总共 {2} 条记录',
emptyMsg: "没有记录"
});
productsgrid = new Ext.grid.EditorGridPanel({
store: productsstore,
cm: cm,
sm: sm,
bodyStyle: 'width:100%',
autoWidth: true,
height: 620,
renderTo: containerid,
autoExpandColumn: 'productId',
frame: true,
clicksToEdit: 2,
plugins: [filters],
loadMask: true,
enableTabScroll: true,
tbar: [{
text: '添加',
tooltip: '添加新记录',
iconCls: 'add',
handler:function(){
openTab("addproducts", "添加products", null, initAddproductsForm);
}
},
'-', {
text: '编辑',
tooltip: '编辑选中记录',
iconCls: 'option',
handler: function() {
var selectedRow = productsgrid.getSelectionModel().getSelections();
if (selectedRow) {
var obj = selectedRow[0];
if (!obj)
return;
var id = obj.get("productId");
openTab("editproducts", "编辑products", null, initAddproductsForm, id, obj);
}
}
},
'-', {
text: '删除',
tooltip: '删除选中记录',
iconCls: 'remove',
handler: function() {
var selectedRow = productsgrid.getSelectionModel().getSelections();
Ext.MessageBox.confirm('Confirm', '你确定要删除你所选定的' + selectedRow.length + "项吗?", function(btn) {
if (btn == 'yes') {
if (selectedRow) {
for (var i = 0; i var obj = selectedRow[i];
var id = obj.get("productId");
productsstore.remove(obj);
$.ajax({
type: "POST",
url: productsDeletePostUrl,
dataType: "json",
data: "recordid=" + id,
success: function(msg) {
if (msg[0] && msg[0].string != "success")
productsstore.reload();
}
});
}
}
}
});
}
}],
bbar: pagingBar
});
productsstore.load({ params: { start: 0, limit: productslimit} });
productsgrid.on("afteredit", afterEdit, productsgrid);
function afterEdit(obj) {
var r = obj.record; //获取被修改的行
var fildname = obj.field; //获取被修改的列
var id = r.get("productId");
var fildval = obj.value;
$.ajax({
type: "POST",
url: productsModifyPostUrl,
dataType: "json",
data: { action: 'modify', fildname: fildname, id: id, fildval: fildval },
complete: function() {
},
success: function(msg) {
}
});
}
}

本文件为ext_add_products.js,用来添加或者编辑products表。
复制代码 代码如下:

var productsAddPostUrl = "/management/procrequest/Proc_products.ashx?action=add";
var productsUpdatePostUrl = "/management/procrequest/Proc_products.ashx?action=update";
function initAddproductsForm(containerid, idstr, rowObj) {
if (!idstr)
idstr = containerid;
var productsForm = new Ext.FormPanel({
labelWidth: 100, // label settings here cascade unless overridden
url: productsAddPostUrl,
frame: true,
bodyStyle: 'padding:5px 5px 0',
autoWidth: true,
defaults: { width: '350' },
defaultType: 'textfield',
renderTo: containerid,
items: [
{
xtype: 'hidden',
name: 'productId',
id: 'productId' + idstr,
value: null == rowObj ? null : rowObj.get("productId"),
readOnly: true
}

, {
xtype: 'textfield',
fieldLabel: '商品名称',
height: 20,
name: 'productName',
allowBlank: false,
value: null == rowObj ? null : rowObj.get("productName"),
id: 'productName' + idstr
}
, {
xtype: 'numberfield',
fieldLabel: '价格',
height: 20,
name: 'money',
allowBlank: false,
value: null == rowObj ? null : rowObj.get("money"),
id: 'money' + idstr
}
, {
xtype: 'textfield',
fieldLabel: '地址',
height: 20,
name: 'address',
value: null == rowObj ? null : rowObj.get("address"),
id: 'address' + idstr
}
, {
xtype: 'textfield',
fieldLabel: '电话',
height: 20,
name: 'tel',
value: null == rowObj ? null : rowObj.get("tel"),
id: 'tel' + idstr
}
, {
xtype: 'myhtmleditor',
fieldLabel: '备注',
height: 400, width: 600,
name: 'remark',
value: null == rowObj ? null : rowObj.get("remark"),
id: 'remark' + idstr
}
, {
xtype: 'numberfield',
fieldLabel: '端口',
height: 20,
name: 'port',
value: null == rowObj ? null : rowObj.get("port"),
id: 'port' + idstr
}
],
buttons: [{
text: '保存',
handler: function() {
if (!productsForm.form.isValid())
return;
productsForm.form.submit({
meghod: 'post',
url: !isNaN(idstr) && parseInt(idstr) > 0 ? productsUpdatePostUrl : productsAddPostUrl,
waitMsg: '正在保存,请稍候...',
success: function() {
Ext.MessageBox.show({
title: '保存结果',
msg: '保存成功',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO
});
},
failure: function() {
Ext.MessageBox.show({
title: '保存结果',
msg: '保存失败',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
}

});

}
}]
});

}
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

深入探討Linux ext2檔案系統的實體儲存結構 深入探討Linux ext2檔案系統的實體儲存結構 Mar 14, 2024 pm 09:06 PM

Linuxext2檔案系統是一種在大部分Linux作業系統上使用的檔案系統,它採用了一種高效的磁碟儲存結構來管理檔案和目錄的儲存。在深入探討Linuxext2檔案系統的實體儲存結構之前,我們首先需要先了解一些基本概念。在ext2檔案系統中,資料儲存在資料塊(block)中,資料塊是檔案系統中最小的可分配單位。每個資料塊有固定的大小,通常為1KB、2KB或4

PHP開發中如何使用程式碼自動產生工具 PHP開發中如何使用程式碼自動產生工具 Jun 27, 2023 pm 02:30 PM

隨著Web開發的快速發展,PHP已成為了Web開發的主要程式語言之一。許多Web開發人員使用PHP編寫他們的應用程序,因為它具有易於學習,易於編寫,並跨平台等優點。然而,對於大型的PHP專案來說,手寫所有的程式碼是十分耗時且費力的。畢竟,我們想要以更有效率的方式完成項目,並快速地開發出滿足客戶要求的應用。因此,我們可以使用PHP自動程式碼產生工具來加速開發流程,幫

ThinkPHP6代碼產生器:快速產生CRUD代碼 ThinkPHP6代碼產生器:快速產生CRUD代碼 Aug 25, 2023 pm 10:24 PM

ThinkPHP6程式碼產生器:快速產生CRUD程式碼前言:在開發過程中,我們常常會遇到需要建立增刪改查(CRUD)的功能。這種重複的勞動既浪費時間,又容易出錯。為了提高開發效率和減少錯誤,我們可以使用一款強大的程式碼產生器來自動產生CRUD程式碼。本文將介紹一款基於ThinkPHP6框架的程式碼產生器,幫助開發者快速產生CRUD程式碼。概述:繁瑣的編碼工作可以透過程式碼

分析Linux ext2檔案系統的實體組織方式 分析Linux ext2檔案系統的實體組織方式 Mar 15, 2024 am 09:24 AM

Linuxext2檔案系統是Linux作業系統中常用的檔案系統之一,具有較好的效能和穩定性。本文將會詳細分析ext2檔案系統的實體組織方式,並提供一些具體的程式碼範例來幫助讀者更好地理解。一、ext2檔案系統概述ext2檔案系統是Linux系統上最早的第二代擴充檔案系統,它在檔案系統的效能、可靠性和穩定性上做了一定的改進。它主要由超級塊、組描

如何使用Python正規表示式進行程式碼產生器開發 如何使用Python正規表示式進行程式碼產生器開發 Jun 22, 2023 pm 04:44 PM

Python正規表示式是一個強大的工具,它可以用於程式碼產生器的開發。程式碼產生器是一個自動化工具,它能夠根據特定的規則和條件產生程式碼或其他文字。這種工具可以節省大量的時間和精力,因為它們可以幫助程式設計師自動化重複性的任務。以下我們將介紹如何使用Python正規表示式進行程式碼產生器開發。理解Python正規表示式Python正規表示式是一種模式匹配的工具,可以用

Linux系統中ext3和ext4有什麼不同? Linux系統中ext3和ext4有什麼不同? Feb 19, 2024 am 11:48 AM

  檔案系統是檔案存放在磁碟等儲存裝置上的組織方法。 Linux系統支援多種目前流行的檔案系統,其中包含:EXT2、EXT3、EXT4、FAT、FAT32等。那麼Linux系統中ext3和ext4有什麼不同?以下是詳細的內容介紹。  Linux系統中ext3和ext4有什麼不同?  1、更大的檔案系統和更大的檔案  ext3:16TB檔案系統和最大2TB檔案;  ext4:1EB檔案系統和最大16TB檔案。  2、無限數量的子目錄  ext3:32000個子目錄;  ext4:無限數量的子目錄。

CentOS建置web伺服器的檔案系統選擇及優化建議 CentOS建置web伺服器的檔案系統選擇及優化建議 Aug 05, 2023 pm 03:35 PM

CentOS建置web伺服器的檔案系統選擇及最佳化建議簡介:在建置web伺服器時,選擇合適的檔案系統並進行最佳化是極為重要的。本文將介紹在CentOS上建置web伺服器時常用的檔案系統,並提供對應的最佳化建議。一、檔案系統選擇XFS檔案系統XFS是一種先進的、高效能的日誌檔案系統。它具有快速高效的檔案系統復原能力,針對大容量儲存的I/O操作效能表現出色。 XFS對大

如何在PHP程式設計中使用程式碼產生器? 如何在PHP程式設計中使用程式碼產生器? Jun 12, 2023 am 09:14 AM

什麼是程式碼產生器?隨著網路技術的不斷發展,越來越多的人開始從事網站開發工作。網站開發需要使用各種程式語言,其中PHP是最受歡迎的語言之一。然而,使用PHP編寫程式碼需要耗費大量的時間和精力,因此,為了提高編碼效率,許多開發人員開始使用程式碼產生器。程式碼產生器是一種自動化工具,可以自動產生符合規範的程式碼。這減少了編碼時間,使得開發人員能夠更快地建立複雜的應用程式

See all articles