Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="report-grid"></div>
- <script type="text/javascript">
- $(function () {
- var productsDataSource = new kendo.data.DataSource({
- transport: {
- read: {
- url: "GridData",
- dataType: "json",
- contentType: 'application/json; charset=utf-8',
- type: 'GET',
- data: { param1: "val1", param2: "val2" } // ارسال اطلاعات اضافي و سفارشي به سرور در حين درخواست
- }
- },
- create: {
- url: "@Url.Action("PostProduct","Home")",
- contentType: 'application/json; charset=utf-8',
- type: "POST"
- },
- update: {
- url: function (TUser) {
- return "@Url.Action("UpdateProduct","Home")/" + TUser.User_ID;
- },
- contentType: 'application/json; charset=utf-8',
- type: "PUT"
- },
- destroy: {
- url: function (product2) {
- return "@Url.Action("DeleteProduct","Home")/" + product.Id;
- },
- contentType: 'application/json; charset=utf-8',
- type: "DELETE"
- },
- parameterMap: function (options) {
- return kendo.stringify(options);
- },
- error: function (e) {
- alert(e.errorThrown.stack);
- },
- pageSize: 20,
- sort: { field: "Id", dir: "desc" },
- batch: false,
- });
- $("#report-grid").kendoGrid({
- dataSource: productsDataSource,
- autoBind: true,
- scrollable: false,
- //pageable: true,
- pageable: {
- previousNext: true, // default true
- numeric: true, // default true
- buttonCount: 5, // default 10
- refresh: true, // default false
- input: true, // default false
- //pageSizes: true, // default false
- pageSizes: [5, 10, 15, 20, 25,50,100], //array of page size choices for user
- info: true // show a label with current paging information in it
- },
- sortable: true,
- filterable: true,
- reorderable: true,
- columnMenu: true,
- groupable: true, // allows the user to alter what field the grid is grouped by
- editable: {
- confirmation: "آيا مايل به حذف رديف انتخابي هستيد؟",
- destroy: true, // whether or not to delete item when button is clicked
- mode: "popup", // options are "incell", "inline", and "popup"
- //template: kendo.template($("#popupEditorTemplate").html()), // template to use for pop-up editing
- update: true, // switch item to edit mode when clicked?
- window: {
- title: "مشخصات محصول" // Localization for Edit in the popup window
- }
- },
- columns: [
- { field: "UserName", title: "شماره", width: "130px" },
- {
- field: "Name", title: "نام محصول",
- footerTemplate: "تعداد: #=count#"
- },
- {
- field: "Family", title: "نام محصول",
- footerTemplate: "تعداد: #=count#"
- },
- {
- command: [
- { name: "edit", text: "ويرايش" },
- { name: "destroy", text: "حذف" }
- ],
- title: " ", width: "260px"
- }
- ],
- toolbar: [
- { name: "create", text: "افزودن ردیف جدید" },
- { name: "save", text: "ذخیرهی تمامی تغییرات" },
- { name: "cancel", text: "لغو کلیهی تغییرات" },
- { template: kendo.template($("#toolbarTemplate").html()) }
- ],
- messages: {
- editable: {
- cancelDelete: "لغو",
- confirmation: "آیا مایل به حذف این رکورد هستید؟",
- confirmDelete: "حذف"
- },
- commands: {
- create: "افزودن ردیف جدید",
- cancel: "لغو کلیهی تغییرات",
- save: "ذخیرهی تمامی تغییرات",
- destroy: "حذف",
- edit: "ویرایش",
- update: "ثبت",
- canceledit: "لغو"
- }
- }
- });
- });
- </script>
- <script>
- // اين اطلاعات براي تهيه خروجي سمت سرور مناسب هستند
- function getCurrentGridFilters() {
- var dataSource = $("#report-grid").data("kendoGrid").dataSource;
- var gridState = {
- page: dataSource.page(),
- pageSize: dataSource.pageSize(),
- sort: dataSource.sort(),
- group: dataSource.group(),
- filter: dataSource.filter()
- };
- return kendo.stringify(gridState);
- }
- </script>
- <script id="toolbarTemplate" type="text/x-kendo-template">
- <a class="k-button" href="#" onclick="alert('gridState: ' + getCurrentGridFilters());">نوار ابزار سفارشي</a>
- </script>
- <script type="text/x-kendo-template" id="priceTemplate">
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement