代码拉取完成,页面将自动刷新
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title>LayUI Table 添加禁止选中</title>
<link href="/2019/05/22/LayUI-Table-%E6%B7%BB%E5%8A%A0%E7%A6%81%E6%AD%A2%E9%80%89%E4%B8%AD/"/>
<url>/2019/05/22/LayUI-Table-%E6%B7%BB%E5%8A%A0%E7%A6%81%E6%AD%A2%E9%80%89%E4%B8%AD/</url>
<content type="html"><![CDATA[<p>LayUI这几年比较流行,里面的Table组件也比较强大,但是前面的CheckBox没有禁止选中功能,今天就来试试,看看能不能给添加一个禁止选中功能。</p><h2 id="Fork-LayUI源码"><a href="#Fork-LayUI源码" class="headerlink" title="Fork LayUI源码"></a>Fork LayUI源码</h2><ul><li><a href="https://github.com/sentsin/layui" target="_blank" rel="noopener">LayUI项目地址</a></li><li>Clone到本地</li><li>找到src里面lay下面的modules文件夹里面的table.js</li></ul><h2 id="添加字段标记"><a href="#添加字段标记" class="headerlink" title="添加字段标记"></a>添加字段标记</h2><ul><li><p>参照这里我们也添加一个”IS_DISABLE”的标记<br><img src="http://pruksi5mp.bkt.clouddn.com/2019-05-22-16-14-50.png" alt="2019-05-22-16-14-50"></p></li><li><p>添加完如下</p><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">config: {</span><br><span class="line"> checkName: <span class="string">'LAY_CHECKED'</span>, <span class="comment">//是否选中状态的字段名</span></span><br><span class="line"> indexName: <span class="string">'LAY_TABLE_INDEX'</span>, <span class="comment">//下标索引名</span></span><br><span class="line"> disableName: <span class="string">'LAY_DISABLED'</span> <span class="comment">//是否禁用</span></span><br><span class="line"> } <span class="comment">//全局配置项</span></span><br></pre></td></tr></table></figure></li></ul><h2 id="修改代码逻辑"><a href="#修改代码逻辑" class="headerlink" title="修改代码逻辑"></a>修改代码逻辑</h2><ul><li><p>找到区域模板里面的 <code>lay-filter="layTableAllChoose"</code><br><img src="http://pruksi5mp.bkt.clouddn.com/2019-05-22-14-55-15.png" alt="2019-05-22-14-55-15"></p></li><li><p>在后面添加如下代码</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">{{# if(item2[d.data.disableName]){ }} disabled {{# }; }}</span><br></pre></td></tr></table></figure><ul><li><p>添加列渲染<br><img src="http://pruksi5mp.bkt.clouddn.com/2019-05-22-16-02-15.png" alt="2019-05-22-16-02-15"></p></li><li><p>修改选择逻辑<br><img src="http://pruksi5mp.bkt.clouddn.com/2019-05-22-16-12-51.png" alt="2019-05-22-16-12-51"><br><img src="http://pruksi5mp.bkt.clouddn.com/2019-05-22-16-13-23.png" alt="2019-05-22-16-13-23"></p></li></ul></li><li><a href="https://github.com/ZeroX-V/layui/commit/a9b20f55c9881916125b9e9e62a1c33b4804a351?diff=unified" target="_blank" rel="noopener">详细修改请点这里</a></li></ul><h2 id="测试"><a href="#测试" class="headerlink" title="测试"></a>测试</h2><ul><li>在数据里面添加 <code>"LAY_DISABLED": true,</code></li><li>来看看效果<br><img src="http://pruksi5mp.bkt.clouddn.com/1234.gif" alt="1234"></li></ul><h2 id="源码"><a href="#源码" class="headerlink" title="源码"></a>源码</h2><ul><li><a href="https://github.com/ZeroX-V/layui/blob/master/src/lay/modules/table.js" target="_blank" rel="noopener">点这里看源码</a></li></ul>]]></content>
<categories>
<category> LayUI </category>
</categories>
<tags>
<tag> LayUI </tag>
<tag> Table </tag>
</tags>
</entry>
<entry>
<title>Hello World</title>
<link href="/2019/05/20/hello-world/"/>
<url>/2019/05/20/hello-world/</url>
<content type="html"><![CDATA[<p>Welcome to <a href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/" target="_blank" rel="noopener">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html" target="_blank" rel="noopener">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues" target="_blank" rel="noopener">GitHub</a>.</p><h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/writing.html" target="_blank" rel="noopener">Writing</a></p><h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/server.html" target="_blank" rel="noopener">Server</a></p><h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/generating.html" target="_blank" rel="noopener">Generating</a></p><h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/deployment.html" target="_blank" rel="noopener">Deployment</a></p>]]></content>
<categories>
<category> Hello </category>
</categories>
</entry>
</search>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。