|
243 | 243 |
|
244 | 244 | const props = field.split('.') |
245 | 245 | for (const p of props) { |
246 | | - if (props.hasOwnProperty(p)) { |
247 | | - value = value && value[props[p]] |
248 | | - } |
| 246 | + value = value && value[p] |
249 | 247 | } |
250 | 248 | return escape ? this.escapeHTML(value) : value |
251 | 249 | }, |
|
1776 | 1774 | type = column.radio ? 'radio' : type |
1777 | 1775 |
|
1778 | 1776 | const c = column['class'] || '' |
| 1777 | + const isChecked = value === true || (value_ || value && value.checked) |
| 1778 | + const isDisabled = !column.checkboxEnabled || (value && value.disabled) |
| 1779 | + |
1779 | 1780 | text = [ |
1780 | 1781 | this.options.cardView |
1781 | 1782 | ? `<div class="card-view ${c}">` |
|
1784 | 1785 | data-index="${i}" |
1785 | 1786 | name="${this.options.selectItemName}" |
1786 | 1787 | type="${type}" |
1787 | | - value="${item[this.options.idField]}" |
1788 | | - ${value === true || (value_ || (value && value.checked)) ? 'checked="checked"' : ''} |
1789 | | - ${!column.checkboxEnabled || (value && value.disabled) ? 'disabled="disabled"' : ''} />`, |
| 1788 | + ${Utils.sprintf('value="%s"', item[this.options.idField])} |
| 1789 | + ${Utils.sprintf('checked="%s"', isChecked ? 'checked' : undefined)} |
| 1790 | + ${Utils.sprintf('disabled="%s"', isDisabled ? 'disabled' : undefined)} />`, |
1790 | 1791 | this.header.formatters[j] && typeof value === 'string' ? value : '', |
1791 | 1792 | this.options.cardView ? '</div>' : '</td>' |
1792 | 1793 | ].join('') |
|
1878 | 1879 | e.type === 'click' && |
1879 | 1880 | this.options.clickToSelect && |
1880 | 1881 | column.clickToSelect && |
1881 | | - this.options.ignoreClickToSelectOn(e.target) |
| 1882 | + !this.options.ignoreClickToSelectOn(e.target) |
1882 | 1883 | ) { |
1883 | 1884 | const $selectItem = $tr.find(Utils.sprintf('[name="%s"]', this.options.selectItemName)) |
1884 | 1885 | if ($selectItem.length) { |
|
1923 | 1924 | const row = this.data[$this.data('index')] |
1924 | 1925 |
|
1925 | 1926 | if ($(e.currentTarget).is(':radio') || this.options.singleSelect) { |
1926 | | - for (let row of this.options.data) { |
1927 | | - row[this.header.stateField] = false |
| 1927 | + for (let r of this.options.data) { |
| 1928 | + r[this.header.stateField] = false |
1928 | 1929 | } |
| 1930 | + this.$selectItem.filter(':checked').not($this).prop('checked', false) |
1929 | 1931 | } |
1930 | 1932 |
|
1931 | 1933 | row[this.header.stateField] = checked |
1932 | 1934 |
|
1933 | | - if (this.options.singleSelect) { |
1934 | | - this.$selectItem.not(this).each((i, el) => { |
1935 | | - this.data[$(el).data('index')][this.header.stateField] = false |
1936 | | - }) |
1937 | | - this.$selectItem.filter(':checked').not(this).prop('checked', false) |
1938 | | - } |
1939 | | - |
1940 | 1935 | this.updateSelected() |
1941 | 1936 | this.trigger(checked ? 'check' : 'uncheck', row, $this) |
1942 | 1937 | }) |
|
2765 | 2760 | } |
2766 | 2761 |
|
2767 | 2762 | getSelections () { |
2768 | | - return (this.options.data, row => // fix #2424: from html with checkbox |
| 2763 | + // fix #2424: from html with checkbox |
| 2764 | + return this.options.data.filter(row => |
2769 | 2765 | row[this.header.stateField] === true) |
2770 | 2766 | } |
2771 | 2767 |
|
|
0 commit comments