hi,
I created asp.net mvc 5 project (.net 4.6.1) using Syncfusion project template for web application in Visual Studio 2015.
Additionally I installed following packages:
Microsoft.AspNet.WebApi.OData - 5.7.0
Microsoft.Data.OData - 5.6.0
Syncfusion.JavaScript - 15.1.0.33
angularJS - 1.2.16
My grid uses angular directives and has WebApiAdaptor.
This is its declaration:
<div ng-app="myapp">
<div ng-controller="myctrl">
<div ej-grid id="Grid" e-datasource="systems"
e-allowpaging="true" e-pagesettings="sys_pageset"
e-allowsorting="true" e-allowmultisorting="false" e-sortsettings="sys_sortset"
e-allowfiltering="true" e-filtersettings="sys_filterset" e-allowsearching="true" e-searchsettings="sys_searchset"
e-allowgrouping="true" e-groupsettings="sys_groupset"
e-toolbarsettings="sys_toolbarset" e-editsettings="sys_editset">
<div e-columns>
<div e-column e-field="Id" e-headertext="Id" e-isprimarykey="true" e-isidentity="true" e-allowfiltering="false" e-allowgrouping="false" e-width="25" e-textalign="right" e-type="number"></div>
<div e-column e-field="Name" e-headertext="Nazwa" e-type="string"></div>
</div>
</div>
</div>
</div>
and this is its configuration:
<script>
(function () {
var app = angular.module('myapp', ['ejangular']);
app.controller('myctrl', function ($scope) {
$scope.systems = ej.DataManager({ url: 'api/app', adaptor: 'WebApiAdaptor' });
$scope.sys_pageset = { pageSize: 2 };
$scope.sys_sortset = { sortedColumns: [{ field: 'Id', direction: 'ascending' }] };
$scope.sys_filterset = { filterType: 'menu', showPredicate: false };
$scope.sys_searchset = { fields: ['Name'], operator: 'contains', key: '', ignoreCase: true };
$scope.sys_groupset = { showToggleButton: true, showDropArea: false };
$scope.sys_toolbarset = { showToolbar: true, toolbarItems: ['search', 'add', 'edit', 'delete'] };
$scope.sys_editset = { allowEditing: true, allowAdding: true, allowDeleting: true, editMode: 'dialog', showDeleteConfirmDialog: true };
});
}());
</script>
controller code is as follows:
public class AppController : ApiController
{
private Models.InMemDb _db = null;
public AppController(Models.InMemDb db)
{
_db = db;
}
public PageResult<Models.Element> Get(ODataQueryOptions opts)
{
var data = _db.Data.AsQueryable();
return new PageResult<Models.Element>(opts.ApplyTo(data) as IEnumerable<Models.Element>, null, _db.Data.Count);
}
public void Post(Models.Element e)
{
e.Id = _db.Data.Count + 1;
_db.Data.Add(e);
}
public void Put(Models.Element e)
{
var d = _db.Data.FirstOrDefault(i => i.Id == e.Id);
if (d != null)
{
d.Name = e.Name;
}
}
public void Delete(int id)
{
var d = _db.Data.FirstOrDefault(i => i.Id == id);
if (d != null)
{
_db.Data.Remove(d);
}
}
}
when I'm adding first record:
then this first row shows on the grid properly:
but when I'm adding second row:
then this second row is added to database but is not showing on the grid (pagesize is set to 2):
seems like grid is not refreshing after adding second record.
please help.
best regards,
Adam
Attachment:
SyncfusionMvcApplication3_ca2c7bf1.zip