Files
vxe-table/examples/views/table/grid/PageProxy.vue
xuliangzhan a9ee2ab7fe update
2019-07-26 21:37:06 +08:00

98 lines
2.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div>
<p>数据代理通过配置 <grid-api-link prop="proxy-config"/> 参数如果配置了 <grid-api-link prop="pager-config"/> 分页则默认读取响应结果中 page.total result 属性可以通过 <grid-api-link prop="props"/> 修改</p>
<p> <grid-api-link prop="pager-config"/> 代理数据转换只需要配置好数据源即可非常简单就可以渲染一个表格</p>
<vxe-grid
border
resizable
height="530"
row-id="id"
:pager-config="{pageSize: 10}"
:proxy-config="tableProxy"
:select-config="{reserve: true}"
:columns="tableColumn"></vxe-grid>
<p class="demo-code">{{ $t('app.body.button.showCode') }}</p>
<pre>
<code class="xml">{{ demoCodes[0] }}</code>
<code class="javascript">{{ demoCodes[1] }}</code>
</pre>
</div>
</template>
<script>
import XEAjax from 'xe-ajax'
import hljs from 'highlight.js'
export default {
data () {
return {
tableProxy: {
index: true, // 启用动态序号代理
props: {
result: 'result',
total: 'page.total'
},
ajax: {
query: ({ page }) => XEAjax.getJSON(`/api/user/page/list/${page.pageSize}/${page.currentPage}`)
}
},
tableColumn: [
{ type: 'selection', width: 50 },
{ type: 'index', width: 60 },
{ field: 'name', title: 'Name' },
{ field: 'nickname', title: 'Nickname' },
{ field: 'role', title: 'Role' },
{ field: 'describe', title: 'Describe', showOverflow: true }
],
demoCodes: [
`
<vxe-grid
border
resizable
height="530"
row-id="id"
:pager-config="{pageSize: 10}"
:proxy-config="tableProxy"
:select-config="{reserve: true}"
:columns="tableColumn"></vxe-grid>
`,
`
export default {
data () {
return {
tableProxy: {
index: true, // 启用动态序号代理
props: {
result: 'result',
total: 'page.total'
},
ajax: {
query: ({ page }) => XEAjax.getJSON(\`/api/user/page/list/\${page.pageSize}/\${page.currentPage}\`)
}
},
tableColumn: [
{ type: 'selection', width: 50 },
{ type: 'index', width: 60 },
{ field: 'name', title: 'Name' },
{ field: 'nickname', title: 'Nickname' },
{ field: 'role', title: 'Role' },
{ field: 'describe', title: 'Describe', showOverflow: true }
]
}
}
}
`
]
}
},
mounted () {
Array.from(this.$el.querySelectorAll('pre code')).forEach((block) => {
hljs.highlightBlock(block)
})
}
}
</script>