mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-06-28 21:20:04 +00:00
20190610 release
This commit is contained in:
@@ -74,7 +74,9 @@
|
||||
</code></pre>
|
||||
<p>In the following, we go though all the predefined editors:</p>
|
||||
<h3><a class="anchor" aria-hidden="true" name="dropdown-editor"></a><a href="#dropdown-editor" aria-hidden="true" class="hash-link" ><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Dropdown Editor</h3>
|
||||
<p>Dropdown editor give a select menu to choose a data from a list, the <code>editor.options</code> is required property for dropdown editor.</p>
|
||||
<p>Dropdown editor give a select menu to choose a data from a list. When use dropdown editor, either <code>editor.options</code> or <code>editor.getOptions</code> should be required prop.</p>
|
||||
<h4><a class="anchor" aria-hidden="true" name="editoroptions"></a><a href="#editoroptions" aria-hidden="true" class="hash-link" ><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>editor.options</h4>
|
||||
<p>This is most simple case for assign the dropdown options data directly.</p>
|
||||
<pre><code class="hljs css js"><span class="hljs-keyword">import</span> { Type } <span class="hljs-keyword">from</span> <span class="hljs-string">'react-bootstrap-table2-editor'</span>;
|
||||
<span class="hljs-keyword">const</span> columns = [
|
||||
..., {
|
||||
@@ -101,6 +103,37 @@
|
||||
}
|
||||
}];
|
||||
</code></pre>
|
||||
<h4><a class="anchor" aria-hidden="true" name="editorgetoptions"></a><a href="#editorgetoptions" aria-hidden="true" class="hash-link" ><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>editor.getOptions</h4>
|
||||
<p>It is much flexible which accept a function and you can assign the dropdown options dynamically.</p>
|
||||
<p>There are two case for <code>getOptions</code>:</p>
|
||||
<ul>
|
||||
<li><em>Synchronous</em>: Just return the options array in <code>getOptions</code> callback function</li>
|
||||
<li><em>Asynchronous</em>: Call <code>setOptions</code> function argument when you get the options from remote.</li>
|
||||
</ul>
|
||||
<pre><code class="hljs css js"><span class="hljs-comment">// Synchronous</span>
|
||||
<span class="hljs-keyword">const</span> columns = [
|
||||
..., {
|
||||
<span class="hljs-attr">dataField</span>: <span class="hljs-string">'type'</span>,
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'Job Type'</span>,
|
||||
<span class="hljs-attr">editor</span>: {
|
||||
<span class="hljs-attr">type</span>: Type.SELECT,
|
||||
<span class="hljs-attr">getOptions</span>: <span class="hljs-function"><span class="hljs-params">()</span> =></span> [.....]
|
||||
}
|
||||
}];
|
||||
|
||||
<span class="hljs-comment">// Asynchronous</span>
|
||||
<span class="hljs-keyword">const</span> columns = [
|
||||
..., {
|
||||
<span class="hljs-attr">dataField</span>: <span class="hljs-string">'type'</span>,
|
||||
<span class="hljs-attr">text</span>: <span class="hljs-string">'Job Type'</span>,
|
||||
<span class="hljs-attr">editor</span>: {
|
||||
<span class="hljs-attr">type</span>: Type.SELECT,
|
||||
<span class="hljs-attr">getOptions</span>: <span class="hljs-function">(<span class="hljs-params">setOptions</span>) =></span> {
|
||||
setTimeout(<span class="hljs-function"><span class="hljs-params">()</span> =></span> setOptions([...]), <span class="hljs-number">1500</span>);
|
||||
}
|
||||
}
|
||||
}];
|
||||
</code></pre>
|
||||
<h3><a class="anchor" aria-hidden="true" name="date-editor"></a><a href="#date-editor" aria-hidden="true" class="hash-link" ><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Date Editor</h3>
|
||||
<p>Date editor is use <code><input type="date"></code>, the configuration is very simple:</p>
|
||||
<pre><code class="hljs css js"><span class="hljs-keyword">const</span> columns = [
|
||||
|
||||
Reference in New Issue
Block a user