<div class="blogpost-body" id="cnblogs_post_body">
<p><span style="font-size:12px;"> </span></p>
<p><span style="color:#000000;font-size:18pt;">GridPanel组件 - 编辑</span></p>
<h1><span style="font-size:12px;"><strong>Ext.grid.plugin.Editing</strong></span></h1>
<p><span style="font-size:12px;">如果要对表格使用列编辑器控件,则需要完成以下几步</span></p>
<p><span style="font-size:12px;">1.将columns中需要编辑的列设为editor并提供编辑列时所要使用的表单控件。</span></p>
<p><span style="font-size:12px;">2.通过配置gridPanel的plugins指向编辑器实例。</span></p>
<p><span style="font-size:12px;">3.指示gridPanel的选择模式为列或行选择模式。</span></p>
<h2><span style="font-size:12px;">列编辑器(Ext.grid.plugin.CellEditing [ ptype: "cellediting" ])</span></h2>
<div class="cnblogs_Highlighter">
<div style="font-family:Arial;background:#1e1e1e;">
<span style="font-size:12px;"><span class="keyword" style="color:#569cd6;">var</span> <span class="identifier">columns</span> <span class="operator" style="color:#b4b4b4;">=</span> <span class="operator" style="color:#b4b4b4;">[</span></span>
<br>
<span style="font-size:12px;"> <span class="operator" style="color:#b4b4b4;">{<!-- --></span> <span class="identifier">header</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="string" style="color:#ff8040;">'编号'</span><span class="operator" style="color:#b4b4b4;">,</span> <span class="identifier">dataIndex</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="string" style="color:#ff8040;">'id'</span> <span class="operator" style="color:#b4b4b4;">},</span></span>
<br>
<span style="font-size:12px;"> <span class="operator" style="color:#b4b4b4;">{<!-- --></span></span>
<br>
<span style="font-size:12px;"> <span class="identifier">header</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="string" style="color:#ff8040;">'性别'</span><span class="operator" style="color:#b4b4b4;">,</span></span>
<br>
<span style="font-size:12px;"> <span class="identifier">dataIndex</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="string" style="color:#ff8040;">'name'</span><span class="operator" style="color:#b4b4b4;">,</span></span>
<br>
<span style="font-size:12px;"> <span class="identifier">editor</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="operator" style="color:#b4b4b4;">{<!-- --></span></span>
<br>
<span style="font-size:12px;"> <span class="identifier">xtype</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="string" style="color:#ff8040;">"combobox"</span><span class="operator" style="color:#b4b4b4;">,</span><span class="comment" style="color:#00a854;">//xtype表示实例化一个组件或控件对象,相当于new Ext.form.combobox(),对象名称全小写。</span></span>
<br>
<span style="font-size:12px;"> <span class="identifier">allowBlank</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="keyword" style="color:#569cd6;">false</span><span class="comment" style="color:#00a854;">//不允许空值</span></span>
<br>
<span style="font-size:12px;"> <span class="operator" style="color:#b4b4b4;">}</span></span>
<br>
<span style="font-size:12px;"> <span class="operator" style="color:#b4b4b4;">},</span></span>
<br>
<span style="font-size:12px;"> <span class="operator" style="color:#b4b4b4;">{<!-- --></span></span>
<br>
<span style="font-size:12px;"> <span class="identifier">header</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="string" style="color:#ff8040;">'描述'</span><span class="operator" style="color:#b4b4b4;">,</span> <span class="identifier">dataIndex</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="string" style="color:#ff8040;">'descn'</span><span class="operator" style="color:#b4b4b4;">,</span> </span>
<br>
<span style="font-size:12px;"> <span class="identifier">editor</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="operator" style="color:#b4b4b4;">{<!-- --></span></span>
<br>
<span style="font-size:12px;"> <span class="identifier">xtype</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="string" style="color:#ff8040;">"textfield"</span><span class="operator" style="color:#b4b4b4;">,</span></span>
<br>
<span style="font-size:12px;"> <span class="identifier">allowBlank</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="keyword" style="color:#569cd6;">false</span><span class="operator" style="color:#b4b4b4;">,</span><span class="comment" style="color:#00a854;">//不允许空值</span></span>
<br>
<span style="font-size:12px;"> <span class="identifier">selectOnFocus</span><span class="operator" style="color:#b4b4b4;">:</span> <span class="keyword" style="color:#569cd6;">true</span><span class="comment" style="color:#00a854;">//点开编辑时自动选中值以便于用户删除。</span></span>
<br>
<span style="font-size:12px;"> <span class="operator" style="color:#b4b4b4;">}</span></span>
<br>
<span style="font- |
|