Javascript - ExtJs - GridPanel组件 - 编辑

论坛 期权论坛     
选择匿名的用户   2021-6-2 17:31   137   0
<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: &#34;cellediting&#34; ])</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;">&#61;</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;">&#39;编号&#39;</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;">&#39;id&#39;</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;">&#39;性别&#39;</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;">&#39;name&#39;</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;">&#34;combobox&#34;</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;">&#39;描述&#39;</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;">&#39;descn&#39;</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;">&#34;textfield&#34;</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-
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP