/** * Allow: Dynamic enabling/disabling of drag and/or drop. * Author: murrah * Post: 21893 #4 */ Ext.ux.TreeDocs = function(config) { Ext.ux.TreeDocs.superclass.constructor.call(this, config); }; /** * Allow: Extend more the Tree. / Add Mask to TreePanel * Author: HACKPRO TM / OutpostMM * Post: - / 43645 #6 */ Ext.extend(Ext.ux.TreeDocs, Ext.tree.TreePanel, { maxNumber: 0, allowDrag: function(allow) { if (allow) { if ( (this.enableDD) || (this.enableDrag) ) { this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || { ddGroup: this.ddGroup || "TreeDD", scroll: this.ddScroll }); } } else if (this.dragZone != undefined) { this.dragZone.unreg(); // Unregister the dragZone so Dragging is disabled. } }, allowDrop: function(allow) { if (allow) { if ( (this.enableDD) || (this.enableDrop) ) { this.dropZone = new Ext.tree.TreeDropZone(this, this.dropConfig || { ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true }); } } else if (this.dropZone != undefined) { this.dropZone.unreg(); // Unregister the dropZone so Dropping is disabled. } }, /** * Allow: Recursive Count Nodes write by HACKPRO TM based in the zesh code. * Author: zesh * Post: 1930 #3 */ recursiveCount: function(node) { if (node.hasChildNodes()) { var totalNodes = 0; // Recurse on all child nodes of the current node. for (var i = 0; i < node.childNodes.length; i++) { totalNodes += node.childNodes.length; this.recursiveCount(node.childNodes[i]); } } return totalNodes; }, recursiveMaxID: function(node) { if (node.hasChildNodes()) { // Recurse on all child nodes of the current node. for (var i = 0; i < node.childNodes.length; i++) { var nID = node.childNodes[i].id; if (nID) { nID = parseInt(nID.replace(/\D/g, ''), 10); } else { nID = -1; } if (nID > this.maxNumber) { this.maxNumber = nID; } this.recursiveMaxID(node.childNodes[i]); } } return this.maxNumber; }, getMaxID: function() { var rootTree = this.getRootNode(); this.recursiveMaxID(rootTree); return this.recursiveMaxID(rootTree); }, getCountNodes: function() { var rootTree = this.getRootNode(); var len = rootTree.childNodes.length + this.recursiveCount(rootTree) + 1; return len; }, removeChildren: function(node) { while (node.firstChild) { var c = node.firstChild; node.removeChild(c); c.destroy(); } }, putRootNode: function(node, jsonData) { this.removeChildren(node); this.getRootNode().appendChild(jsonData); }, /** * @cfg {Boolean} mask Indicates if the tree panel should have a loadmask applied when loading nodes */ mask: false, maskObject: null, /** * @cfg {Object} maskConfig A configuration object that can be applied to the loadmask. */ maskConfig: { msg: "Cargando..." }, // init initComponent:function() { // call parent Ext.ux.TreeDocs.superclass.initComponent.apply(this, arguments); if (this.mask) { this.on('render', this.createMask, this); } }, // end initComponent /** * @private */ createMask: function() { if (this.maskObject == null) { var mask = new Ext.LoadMask(this.getEl(), this.maskConfig); } else { var mask = new Ext.LoadMask(this.maskObject, this.maskConfig); } this.getLoader().on('beforeload', mask.show, mask); this.getLoader().on('load', mask.hide, mask); } }); Ext.reg("treedocs", Ext.ux.TreeDocs);
sábado, junio 05, 2010
Extendiendo un control TreePanel
viernes, junio 04, 2010
JavaScript image combobox v2.1 by Marghoob Suleman
Encontré hace algunos días, este gran Jquery Plugin, hice un pequeño skin para el mismo y adicione un pequeño código para arreglar un problema al cargar con elementos no visibles inicialmente.
El código original lo pueden descargar de http://www.marghoobsuleman.com/jquery-image-dropdown
Como se vería el skin que hice
Pueden descargar el skin desde aquí
No olviden visitar la web del autor.
El código original lo pueden descargar de http://www.marghoobsuleman.com/jquery-image-dropdown
Como se vería el skin que hice
Pueden descargar el skin desde aquí
No olviden visitar la web del autor.
Etiquetas:
ComboBox,
ImageComboBox,
Jquery
domingo, mayo 23, 2010
Generic Code to use any SQLite DB with C#
How use SQLite Database with C# and System.Data.SQLite using SharpDevelop
Original by Zhanshan Dong
Original by Zhanshan Dong
/* * Original by Zhanshan Dong * A little modified by HACKPRO TM. * Created: 22/05/2010 * Hour: 10:20 p.m. * */ using System; using System.Windows.Forms; using System.Data; using System.Data.SQLite; using System.IO; public class ConnSQLite { private SQLiteConnection Conn; private SQLiteCommand Cmd; private bool isConnect = false; public ConnSQLite(string dbName, string connection) { bool hasDBFile = File.Exists(dbName); if (hasDBFile == true) { ConnectDB(connection); Cmd = CreateCMD(); } else { isConnect = false; } } ~ConnSQLite() { if (isConnect == true) { Cmd.Dispose(); Conn.Close(); } } private void ConnectDB(string connection) { Conn = new SQLiteConnection(connection); Conn.Open(); if (Conn.State.ToString() == "Open") { isConnect = true; } else { isConnect = false; } } private SQLiteCommand CreateCMD() { SQLiteCommand cmd = new SQLiteCommand(); return Conn.CreateCommand(); } private void disposeCMD(SQLiteCommand cmd) { cmd.Dispose(); } public bool IsConnect() { return isConnect; } public void ExecuteNonQuerySQL(string SQL) { Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); } public SQLiteDataReader ExecuteQuerySQL(string SQL, SQLiteCommand cmd) { cmd.CommandText = SQL; return cmd.ExecuteReader(); } public DataTable RecordSet(string SQL) { SQLiteDataAdapter da = new SQLiteDataAdapter(SQL, Conn); DataSet ds = new DataSet(); DataTable dt = new DataTable(); ds.Reset(); da.Fill(ds); dt = ds.Tables[0]; return dt; } public double MAXId(string SQL) { SQLiteCommand cmd = CreateCMD(); SQLiteDataReader dbReader = ExecuteQuerySQL(SQL, cmd); double rowVal = 0; if (dbReader.HasRows == true) { while (dbReader.Read()) { rowVal = dbReader.GetDouble(0); } } else { rowVal = 0; } dbReader.Close(); cmd.Dispose(); return rowVal; } public int getRowCount(string SQL) { SQLiteCommand cmd = CreateCMD(); SQLiteDataReader dbReader = ExecuteQuerySQL(SQL, cmd); int rowCount = 0; if (dbReader.HasRows) { dbReader.Read(); rowCount = dbReader.GetInt32(0); } dbReader.Close(); cmd.Dispose(); return rowCount; } }
Etiquetas:
C#,
Database,
SQLite,
System.Data.SQLite
Prevent Loop No-Leaf Nodes in ExtJS TreeView
Using this overrider function you can stop the loading waiting loop in the TreeView.
/** * Allow: Stop loading No-Leaf Node. * Author: HACKPRO TM * Post: - */ Ext.override(Ext.tree.TreeLoader, { load: function(A, B) { if (this.clearOnLoad) { while (A.firstChild) { A.removeChild(A.firstChild); } } if (this.doPreload(A)) { if (typeof B == "function") { B(); } } else if (this.dataUrl || this.url) { this.requestData(A, B); } else if (typeof B == "function") { B(); } } }); Ext.override(Ext.tree.TreeNodeUI, { updateExpandIcon : function() { if (this.rendered) { var n = this.node, c1, c2; var cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow"; var hasChild = n.hasChildNodes(); var cls1 = ''; if (hasChild || n.attributes.expandable || n.attributes.isFolder) { if (n.expanded) { cls1 = "-minus"; c1 = "x-tree-node-collapsed"; c2 = "x-tree-node-expanded"; } else { cls1 = "-plus"; c1 = "x-tree-node-expanded"; c2 = "x-tree-node-collapsed"; } if (this.wasLeaf) { this.removeClass("x-tree-node-leaf"); this.wasLeaf = false; } if (n.attributes.isFolder && n.attributes.leaf) { cls1 = ''; } cls += cls1; if (this.c1 != c1 || this.c2 != c2) { Ext.fly(this.elNode).replaceClass(c1, c2); this.c1 = c1; this.c2 = c2; } } else { if (!this.wasLeaf) { Ext.fly(this.elNode).replaceClass("x-tree-node-expanded", "x-tree-node-leaf"); delete this.c1; delete this.c2; this.wasLeaf = true; } } var ecc = "x-tree-ec-icon " + cls; if (this.ecc != ecc) { this.ecNode.className = ecc; this.ecc = ecc; } } } });
Etiquetas:
ExtJS,
No-Leaf Nodes,
TreePanel,
TreeView
Suscribirse a:
Entradas (Atom)