2009-06-15 28 views
3

出现一个有趣的问题。在ExtJs网格中无法选择文本字段

输出具有自定义渲染的GridPanel。渲染器在运行时输出基本的html输入字段,但是我无法在输入中选择文本。我可以编辑它,但如果我不得不在输入框中单击并拖动,我将无法选择文本。

这里是一个exerpt:

tsGrid = new Ext.grid.GridPanel({ 
     id   : 'gridTimes', 
     store  : gridStore, 
     border  : false, 
     deletedLineIDs : [], 
     viewConfig : { 
      forceFit : true 
     }, 
     plugins  : [ 
      actionColumn 
     ], 
     cm   : new Ext.grid.ColumnModel([ 
      {id:'client',header: "client", width: 40, sortable: true, dataIndex: 'client'}, 
      {header: "product", width: 20, sortable: true, dataIndex: 'product'}, 
      {header: "job", width: 20, sortable: true, dataIndex: 'job'}, 
      {header: "task", width: 20, sortable: true, dataIndex: 'task'}, 
      {header: "notes", width: 20, sortable: true, dataIndex: 'notes'}, 
      {header: "cancomplete", width: 20, sortable: true, dataIndex: 'cancomplete'}, 
      {header: "Monday", width: 20, sortable: true, dataIndex: '0', cls : 'suppresspadding mon',renderer : function(v, p, record){return '<input tsid="' + record.id + '" class="x-form-field x-form-text" unselectable="off" onFocus="this.select()" value="' + v + '">';}}, 
      {header: "Tuesday", width: 20, sortable: true, dataIndex: '1', cls : 'suppresspadding tue',renderer : function(v, p, record){return '<input tsid="' + record.id + '" class="x-form-field x-form-text" onFocus="this.select()" value="' + v + '">';}}, 
      {header: "Wednesday", width: 20, sortable: true, dataIndex: '2', cls : 'suppresspadding wed',renderer : function(v, p, record){return '<input tsid="' + record.id + '" class="x-form-field x-form-text" onFocus="this.select()" value="' + v + '">';}}, 
     ]) 
    }) 

什么想法?

回答

3

虽然选择了“”文本行为,但下面的CSS会阻止视觉选择。

.X-GRID3排TD,.X-GRID3-摘要列 TD {线高度:13像素;垂直对齐:顶部;填充左:1px的;填充右:1px的; -moz-user-select:none;}

REMOVE“-moz-user-select:none;”显示文本被选中。

0

ExtJS内置了解决此问题的解决方案Editable Grid。它充当一个常规的网格,但是可以让您选择某些列进行编辑。如果您重写渲染器,则甚至可以仅使列中的特定行可编辑。

+0

是的我已经使用了可编辑网格,但一次只能编辑一个字段。我们需要一次打开整个网格,以便人们可以保持低调,在捕获信息时查看信息。虽然 – StevenMcD 2009-06-18 05:02:53

+1

感谢您可以使用可编辑的网格。你可以设置触发“编辑”的事件,当它被选中时开始激活,因此用户可以只输入,选项卡,类型,标签等。 – 2009-06-18 05:50:40

+0

听起来像一个计划,让我看看,谢谢! – StevenMcD 2009-06-19 13:18:36

0

尝试设置:

tsGrid.getView().dragZone = null; (or empty object) 

Ext.grid.GridDragZone,详细了解在建网拖欧米茄下降的特点。我怀疑这会阻止你选择输入中的文本。

0

仅供参考:在不同的方向上做,即。使元素非文本可选,使用应该在所有浏览器中工作的Ext.Element unselectable() function

例如,在一个小部件中,您可以拨打this.el.unselectable()