You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/javascript/data/datasource.md
+29-10Lines changed: 29 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1503,24 +1503,43 @@ The following options are sent to the server when server paging is enabled:
1503
1503
-`skip` - The number of data items to skip.
1504
1504
-`take` - The number of data items to return (the same as `pageSize`).
1505
1505
1506
+
The `skip` and `take` values are automatically calculated based on the current `page` and `pageSize`. This means that a dataSource with `page` = 3 and `pageSize` = 20 will generate a request that has `skip` = 40 and `take` = 20.
1507
+
1506
1508
Use the [`parameterMap`](/api/javascript/data/datasource#configuration-transport.parameterMap) option to send the paging options in a different format.
1507
1509
1508
-
For more information and tips about client and server data operations, refer to the [introductory article on the DataSource](/framework/datasource/overview#mixed-data-operations-mode).
1510
+
For more information and tips about client and server data operations, refer to the [introductory article on the DataSource]({% slug overview_kendoui_datasourcecomponent %}#mixed-data-operations-mode).
1509
1511
1510
1512
For a runnable example with enabled server paging, you can visit [the Grid remote data binding demo.](https://demos.telerik.com/kendo-ui/grid/remote-data-binding)
1511
1513
1512
1514
#### Example - enable server paging
1513
1515
1516
+
<div id="container"></div>
1517
+
1514
1518
<script>
1515
-
var dataSource = new kendo.data.DataSource({
1516
-
transport: {
1517
-
/* transport configuration */
1518
-
},
1519
-
serverPaging: true,
1520
-
schema: {
1521
-
total: "total" // total is returned in the "total" field of the response
1522
-
}
1523
-
});
1519
+
var dataSource = new kendo.data.DataSource({
1520
+
transport: {
1521
+
// The remote endpoint which will receive the request parameters and return the response containing the data.
page: 3 // Change the page property to see a different set of items. The endpoint contains 77 items in total. This means that there are eight pages (eight pages multiplied by 10 records each).
1530
+
});
1531
+
1532
+
// The remote endpoint is configured to return the items in descending order. The first item is with ID = 77, the last item is with ID = 1
1533
+
dataSource.fetch(function() {
1534
+
let data = this.data(),
1535
+
currentPage = this.page();
1536
+
1537
+
// For demo purposes, each item in the current page is rendered on the screen.
1538
+
data.forEach((item) => {
1539
+
let element = `<p>ID - ${item.ProductID}, Name = ${item.ProductName}, Page = ${currentPage}</p>`;
Copy file name to clipboardExpand all lines: docs/api/javascript/ui/grid.md
+60-36Lines changed: 60 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2873,6 +2873,12 @@ Each table row consists of table cells (`<td>`) which represent the grid columns
2873
2873
2874
2874
> Use the `template` to customize the way the column displays its value.
2875
2875
2876
+
For additional and more complex examples that utilize column templates, visit the [`Knowledge Base`](https://docs.telerik.com/kendo-ui/knowledge-base) documentation, and use the following search terms:
2877
+
2878
+
- column template
2879
+
- grid column template
2880
+
- Column Template | Kendo UI Grid
2881
+
2876
2882
#### Example - set the template as a string (wrap the column value in HTML)
2877
2883
2878
2884
<div id="grid"></div>
@@ -3622,29 +3628,37 @@ The text message displayed in the column menu for unlocking a column.
The data source of the widget which is used render table rows. Can be a JavaScript object which represents a valid data source configuration, a JavaScript array or an existing [kendo.data.DataSource](/api/javascript/data/datasource)
3626
-
instance.
3631
+
The data source of the Grid holds the items that will be rendered inside the widget. An item can be a JavaScript object which represents a valid data source configuration, a JavaScript array, or an existing [kendo.data.DataSource](/api/javascript/data/datasource) instance.
3627
3632
3628
-
If the `dataSource` option is set to a JavaScript object or array the widget will initialize a new [kendo.data.DataSource](/api/javascript/data/datasource) instance using that value as data source configuration.
3633
+
If the `dataSource` option is set to a JavaScript object or array, the widget will initialize a new [kendo.data.DataSource](/api/javascript/data/datasource) instance by using that value as a data source configuration.
3629
3634
3630
3635
If the `dataSource` option is an existing [kendo.data.DataSource](/api/javascript/data/datasource) instance the widget will use that instance and will **not** initialize a new one.
3631
3636
3632
-
#### Example - set dataSource as a JavaScript object
3637
+
> For live demos and more complex configurations, refer to the article on [binding the Grid to local data](https://demos.telerik.com/kendo-ui/grid/local-data-binding) and [binding the Grid to remote data](https://demos.telerik.com/kendo-ui/grid/remote-data-binding).
3638
+
3639
+
#### Example - set dataSource as a JavaScript object with data, page and pageSize properties
3633
3640
3634
3641
<div id="grid"></div>
3635
3642
<script>
3636
-
$("#grid").kendoGrid({
3637
-
columns: [
3638
-
{ field: "name" },
3639
-
{ field: "age" }
3640
-
],
3641
-
dataSource: {
3642
-
data: [
3643
-
{ name: "Jane Doe", age: 30 },
3644
-
{ name: "John Doe", age: 33 }
3645
-
]
3646
-
}
3647
-
});
3643
+
$("#grid").kendoGrid({
3644
+
columns: [
3645
+
{ field: "name" },
3646
+
{ field: "age" }
3647
+
],
3648
+
pageable: true,
3649
+
// The dataSource configuration is an object which contains some data and a couple of configurations.
3650
+
dataSource: {
3651
+
data: [
3652
+
{ name: "Jane Doe", age: 30 },
3653
+
{ name: "John Doe", age: 33 },
3654
+
{ name: "Mike Doe", age: 31 },
3655
+
{ name: "Tom Doe", age: 35 },
3656
+
{ name: "Danny Doe", age: 37 }
3657
+
],
3658
+
pageSize: 2, // The number of items displayed per page
3659
+
page: 2 // Page 2 will be opened by default when the Grid loads.
3660
+
}
3661
+
});
3648
3662
</script>
3649
3663
3650
3664
#### Example - set dataSource as a JavaScript array
@@ -3656,6 +3670,7 @@ If the `dataSource` option is an existing [kendo.data.DataSource](/api/javascrip
3656
3670
{ field: "name" },
3657
3671
{ field: "age" }
3658
3672
],
3673
+
// The dataSource configuration is a simple array with no additional configurations.
3659
3674
dataSource: [
3660
3675
{ name: "Jane Doe", age: 30 },
3661
3676
{ name: "John Doe", age: 33 }
@@ -3667,23 +3682,25 @@ If the `dataSource` option is an existing [kendo.data.DataSource](/api/javascrip
3667
3682
3668
3683
<div id="grid"></div>
3669
3684
<script>
3685
+
// The dataSource is initialized as a stand-alone widget that can be bound to the Grid.
3670
3686
var dataSource = new kendo.data.DataSource({
3671
3687
transport: {
3672
3688
read: {
3689
+
// The remote endpoint from which the data is retrieved.
// The dataSource configuration is set to an existing DataSource instance.
3680
3699
dataSource: dataSource,
3681
3700
pageable: true
3682
3701
});
3683
3702
</script>
3684
3703
3685
-
> Check [Binding to local data](https://demos.telerik.com/kendo-ui/grid/local-data-binding) and [Binding to remote data](https://demos.telerik.com/kendo-ui/grid/remote-data-binding) for live demos.
3686
-
3687
3704
### detailTemplate `String|Function`
3688
3705
3689
3706
The [template](/api/javascript/kendo/methods/template) which renders the detail rows.
@@ -9572,27 +9589,34 @@ Fires the [edit](/api/javascript/ui/grid/events/edit) event.
0 commit comments