import $ from "jquery";
import '../css/admin_locale.scss';
import 'bootstrap';
import {setCulture, L10n, Ajax} from '@syncfusion/ej2-base';
import {Button} from '@syncfusion/ej2-buttons';
import {Grid, Filter, Page, Sort, Search, Edit, Toolbar, RowDataBoundEventArgs } from '@syncfusion/ej2-grids'
import {DataManager, RemoteSaveAdaptor, ODataV4Adaptor } from '@syncfusion/ej2-data';
import * as EJ2_LOCALE from "@syncfusion/ej2-locale/src/pl.json";
import {FormValidator, FormValidatorModel} from '@syncfusion/ej2-inputs';
let mainUrl = "/admin/locale";
L10n.load({pl: EJ2_LOCALE.pl});
setCulture('pl');
Grid.Inject(Filter, Page, Sort, Search, Toolbar, Edit);
let myGrid = new Grid({
// dataSource: null,
locale: 'pl',
toolbar: ['Search', 'Add', 'Edit', 'Delete', 'Update', 'Cancel'],
// editSettings: {allowEditing: true, allowAdding: true, allowDeleting: true},
editSettings: { showDeleteConfirmDialog: true, allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal' },
searchSettings: {operator: 'contains', ignoreCase: true},
columns: [
{ field: "id", isPrimaryKey: true, visible:false },
{field: 'position', textAlign: 'Right', type: 'integer', validationRules: { required: true, digits: true }},
{field: 'name', type: 'string', validationRules: { required: true }},
{field: 'shortcut', textAlign: 'Right', format: 'string', validationRules: { required: true, minLength: 2, maxLength: 2 }},
],
// rowDataBound: rowBound,
height: 175,
allowFiltering: true,
filterSettings: {type: 'Excel', ignoreAccent: true},
allowPaging: true,
pageSettings: {pageSize: 6},
allowSorting: true,
actionFailure: (e) => {
let span = document.createElement('span');
myGrid.element.parentNode.insertBefore(span, myGrid.element);
span.style.color = '#FF0000'
span.innerHTML = 'Server exception: 404 Not found';
},
});
myGrid.appendTo('#table_container');
myGrid.showSpinner();
let ajaxObj = new Ajax();
ajaxObj.url = '/admin/locale/es_data_list';
ajaxObj.type = 'GET';
ajaxObj.send().then(function (value) {
let dataajax = JSON.parse(value);
myGrid.dataSource = new DataManager({
json: dataajax,
adaptor: new RemoteSaveAdaptor, //remote save adaptor
insertUrl: mainUrl + '/es_data_insert',
updateUrl: mainUrl + '/es_data_update',
removeUrl: mainUrl + '/es_data_delete'
});
});
|
// Grid’s rowDataBound event handler
function onRowDataBound(args) {
// Custom attribute is added to the grid row element
args.row.setAttribute("data-identifier", "" + args.data.OrderID);
} |