We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to get the maximum number in a grid column


I have a requirement to get the maximum number in a column. In EJ1 I did it as bellow and how do I do it in EJ2.


var gridObj = $("#FlatGrid").data("ejGrid");

var NewLineNo = ej.max(gridObj.model.dataSource, "LinNo").LinNo + 1;

Thank you and best regards,


3 Replies 1 reply marked as answer

RS Rajapandiyan Settu Syncfusion Team March 10, 2023 11:45 AM UTC

Hi Kalum,

Thanks for contacting Syncfusion support.

By using the EJ2 Datautil/ DataManager, you can get the maximum value of a particular field from the JSON data.


// get the sorted data using DataUtil

var sortedData = ej.data.DataUtil.sort(window.orderData, 'OrderID', ej.data.DataUtil.fnDescending);

// get the maximum value of OrderID

if (sortedData.length) {

  maxnumber1 = sortedData[0]['OrderID'];


  document.getElementById('Grid').innerText = 'Max number is - ' + maxnumber1;



// get the sorted data using DataManager with take query as 1

var maxNubmerRecord = new ej.data.DataManager(window.orderData).executeLocal(

  new ej.data.Query().sortBy('OrderID', 'descending').take(1));

// get the maximum value of OrderID

if (maxNubmerRecord.length) {

  maxnumber2 = maxNubmerRecord[0]['OrderID'];




Sample: https://stackblitz.com/edit/cxwtnn?file=index.js


Rajapandiyan S

Marked as answer

KA kalum March 13, 2023 10:11 AM UTC

Hi Rajapandiyan,

Your solution works great. Thank you very much for the support




RS Rajapandiyan Settu Syncfusion Team March 14, 2023 03:54 AM UTC


We are happy to hear that you have achieved your requirement with the solution provided.

Please get back to us if you need further assistance.


Rajapandiyan S
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.

Live Chat Icon For mobile
Up arrow icon