Skip to content

Commit

Permalink
Merge pull request #1 from wenzhixin/develop
Browse files Browse the repository at this point in the history
update
  • Loading branch information
djhvscf committed May 29, 2018
2 parents cdbd51f + ea5610e commit 7ff53f1
Show file tree
Hide file tree
Showing 6 changed files with 237 additions and 230 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"scripts": {
"grunt": "grunt",
"postinstall": "opencollective postinstall || exit 0",
"lint": "eslint src/bootstrap-table.js src/extensions/export/bootstrap-table-export.js"
"lint": "eslint src/bootstrap-table.js src/extensions/export/bootstrap-table-export.js src/extensions/toolbar/bootstrap-table-toolbar.js"
},
"repository": {
"type": "git",
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap-table.css
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@
position: relative;
margin-top: 10px;
margin-bottom: 10px;
line-height: 34px;
}

.fixed-table-pagination li.disabled a {
Expand Down Expand Up @@ -308,7 +307,7 @@ div.fixed-table-scroll-outer {
clear: both;
}

.fullscreen {
.bootstrap-table.fullscreen {
position: fixed;
top: 0;
left: 0;
Expand Down
59 changes: 27 additions & 32 deletions src/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,8 @@
}

const props = field.split('.')
for (const p in props) {
if (props.hasOwnProperty(p)) {
value = value && value[props[p]]
}
for (const p of props) {
value = value && value[p]
}
return escape ? this.escapeHTML(value) : value
},
Expand Down Expand Up @@ -1239,7 +1237,9 @@
this.searchText = text
this.options.searchText = text

this.options.pageNumber = 1
if (!firedByInitSearchText) {
this.options.pageNumber = 1
}
this.initSearch()
if (firedByInitSearchText) {
if (this.options.sidePagination === 'client') {
Expand Down Expand Up @@ -1776,6 +1776,9 @@
type = column.radio ? 'radio' : type

const c = column['class'] || ''
const isChecked = value === true || (value_ || value && value.checked)
const isDisabled = !column.checkboxEnabled || (value && value.disabled)

text = [
this.options.cardView
? `<div class="card-view ${c}">`
Expand All @@ -1784,9 +1787,9 @@
data-index="${i}"
name="${this.options.selectItemName}"
type="${type}"
value="${item[this.options.idField]}"
${value === true || (value_ || (value && value.checked)) ? 'checked="checked"' : ''}
${!column.checkboxEnabled || (value && value.disabled) ? 'disabled="disabled"' : ''} />`,
${Utils.sprintf('value="%s"', item[this.options.idField])}
${Utils.sprintf('checked="%s"', isChecked ? 'checked' : undefined)}
${Utils.sprintf('disabled="%s"', isDisabled ? 'disabled' : undefined)} />`,
this.header.formatters[j] && typeof value === 'string' ? value : '',
this.options.cardView ? '</div>' : '</td>'
].join('')
Expand Down Expand Up @@ -1878,7 +1881,7 @@
e.type === 'click' &&
this.options.clickToSelect &&
column.clickToSelect &&
this.options.ignoreClickToSelectOn(e.target)
!this.options.ignoreClickToSelectOn(e.target)
) {
const $selectItem = $tr.find(Utils.sprintf('[name="%s"]', this.options.selectItemName))
if ($selectItem.length) {
Expand Down Expand Up @@ -1919,26 +1922,7 @@
e.stopImmediatePropagation()

const $this = $(e.currentTarget)
const checked = $this.prop('checked')
const row = this.data[$this.data('index')]

if ($(e.currentTarget).is(':radio') || this.options.singleSelect) {
for (let row of this.options.data) {
row[this.header.stateField] = false
}
}

row[this.header.stateField] = checked

if (this.options.singleSelect) {
this.$selectItem.not(this).each((i, el) => {
this.data[$(el).data('index')][this.header.stateField] = false
})
this.$selectItem.filter(':checked').not(this).prop('checked', false)
}

this.updateSelected()
this.trigger(checked ? 'check' : 'uncheck', row, $this)
this.check_($this.prop('checked'), $this.data('index'))
})

this.header.events.forEach((events, i) => {
Expand Down Expand Up @@ -2765,7 +2749,8 @@
}

getSelections () {
return (this.options.data, row => // fix #2424: from html with checkbox
// fix #2424: from html with checkbox
return this.options.data.filter(row =>
row[this.header.stateField] === true)
}

Expand Down Expand Up @@ -2817,8 +2802,18 @@
}

check_ (checked, index) {
const $el = this.$selectItem.filter(Utils.sprintf('[data-index="%s"]', index)).prop('checked', checked)
this.data[index][this.header.stateField] = checked
const $el = this.$selectItem.filter(`[data-index="${index}"]`)
const row = this.data[index]

if ($el.is(':radio') || this.options.singleSelect) {
for (let r of this.options.data) {
r[this.header.stateField] = false
}
this.$selectItem.filter(':checked').not($this).prop('checked', false)
}

row[this.header.stateField] = checked
$el.prop('checked', checked)
this.updateSelected()
this.trigger(checked ? 'check' : 'uncheck', this.data[index], $el)
}
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/editable/bootstrap-table-editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
};
column._formatter = column._formatter ? column._formatter : column.formatter;
column.formatter = function(value, row, index) {
var result = column._formatter ? column._formatter(value, row, index) : value;
var result = $.fn.bootstrapTable.utils.calculateObjectValue(column, column._formatter, [value, row, index], value);

$.each(column, processDataOptions);

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/filter-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Dependence if you use the datepicker option: [bootstrap-datepicker](https://gith
### filterData

* type: String
* description: Set custom select filter values, use `var:variable` to load from a variable or `url:http://www.example.com/data.json` to load from a remote json file or `jso:{key:data}` to load from a json string.
* description: Set custom select filter values, use `var:variable` to load from a variable or `url:http://www.example.com/data.json` to load from a remote json file or `json:{key:data}` to load from a json string.
* default: `undefined`

### filterDatepickerOptions
Expand Down
Loading

0 comments on commit 7ff53f1

Please sign in to comment.