<EjsGrid id="Grid" ref="@grid" AllowSorting="true" AllowPaging="true" Toolbar="@(new List<string> { "Add", "Edit", "Delete", "Update", "Cancel"})">
<GridPageSettings PageSize="4"></GridPageSettings>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" ></GridEditSettings>
<GridColumns>
<GridColumn Field="EmployeeID" HeaderText="Employee ID" IsPrimaryKey="true" TextAlign="@Syncfusion.EJ2.RazorComponents.Grids.TextAlign.Right" Width="90"></GridColumn>
. . . .
</GridColumns>
</EjsGrid>
@functions{
Employee[] data;
EjsGrid grid;
} |
namespace WebApplication1.Server.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class DefaultController : ControllerBase
{
EmployeeDataAccessLayer objemployee = new EmployeeDataAccessLayer();
// GET: api/Default
[HttpGet]
public object Get()
{
IEnumerable<Employee> data = objemployee.GetAllEmployees().ToList();
var count = data.Count();
var queryString = Request.Query;
if (queryString.Keys.Contains("$inlinecount"))
{
StringValues Skip;
StringValues Take;
int skip = (queryString.TryGetValue("$skip", out Skip)) ? Convert.ToInt32(Skip[0]) : 0;
int top = (queryString.TryGetValue("$top", out Take)) ? Convert.ToInt32(Take[0]) : data.Count();
return new { Items = data.Skip(skip).Take(top), Count = count };
}
else
{
return data;
}
}
// GET: api/Default/5
[HttpGet("{id}", Name = "Get")]
public string Get(int id)
{
return "value";
}
// POST: api/Default
[HttpPost]
public void Post([FromBody]Employee employee)
{
/// code for Insert operation
}
// PUT: api/Default/5
[HttpPut]
public void Put([FromBody] Employee employee)
{
/// code for Update operation
}
// DELETE: api/ApiWithActions/5
[HttpDelete("{id}")]
public void Delete(int id)
{
//// code for delete operation
}
}
} |
<EjsGrid id="Grid" ref="@grid" AllowSorting="true" AllowPaging="true" Toolbar="@(new List<string> { "Add", "Edit", "Delete", "Update", "Cancel"})">
<EjsDataManager Url="https://ej2services.syncfusion.com/production/web-services/api/Orders" Adaptor="@Syncfusion.EJ2.RazorComponents.Adaptors.WebApiAdaptor" CrossDomain=true></EjsDataManager>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" ></GridEditSettings>
<GridColumns>
<GridColumn Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@Syncfusion.EJ2.RazorComponents.Grids.TextAlign.Right" Width="90"></GridColumn>
. . . .
</GridColumns>
</EjsGrid>
@functions{
Employee[] data;
EjsGrid grid;
}
|