- Home
- Forum
- ASP.NET Core - EJ 2
- Grid not showing data
Grid not showing data
I have a grid that is pulling data from SQL Server that works perfectly fine in one case but as soon as I add an .Include(a => a.Measure) to the equation it no longer shows the data. The data is present during debug right up till the OnPostLoadData end but nothing displayed when the Include is used.
ejs-grid id="Grid" allowPaging="true" allowSorting="true" allowSelection="true" load="onLoad" actionFailure="onActionFailure" height="550" width="1850" toolbar="@( new List<object>() { "Search", "Add" })">
<e-grid-editsettings allowDeleting="true" allowEditing="true" allowAdding="true" showDeleteConfirmDialog="true"></e-grid-editsettings>
<e-data-manager url="CurrentScorecard?handler=LoadData" insertUrl="CurrentScorecard?handler=Insert" removeUrl="CurrentScorecard?handler=Delete" updateUrl="CurrentScorecard?handler=Update" adaptor="UrlAdaptor"></e-data-manager>
<e-grid-filtersettings type="Excel"></e-grid-filtersettings>
<e-grid-pagesettings pageCount="5"></e-grid-pagesettings>
<e-grid-columns>
<e-grid-column field="AggregateScorecardId" headerText="AggregateScorecardId" isPrimaryKey="true" isIdentity="true" textAlign="Right" visible="false"></e-grid-column>
<e-grid-column field="MeasureId" headerText="Measure" editType="dropdownedit" foreignKeyField="measure" foreignKeyValue="measureId" dataSource="ViewBag.MeasureData"></e-grid-column>
...
<e-grid-column headerText="Manage Records" width="150" commands="commands"></e-grid-column>
</e-grid-columns>
</ejs-grid>
public JsonResult OnPostLoadData([FromBody]DataManagerRequest dm)
{
IEnumerable scorecard = _context.AggregateScorecard
.Where(a => a.CurrentScorecard == true)
.Include(m => m.Measure) <-- This causes the grid to show no data, if commented out grid shows data
.OrderBy(a => a.Measure.Outcome.Aim.ItemOrder)
.ThenBy(a => a.Measure.Outcome.Outcome1)
.ThenByDescending(a => a.PeriodStart)
.ToList();
int count = _context.AggregateScorecard
.Where(a => a.CurrentScorecard == true)
.Count();
DataOperations operation = new DataOperations();
scorecard = operation.Execute(scorecard, dm);
return new JsonResult(new { result = scorecard, count = count }, new JsonSerializerSettings());
}
AggregateScorecard model
public partial class AggregateScorecard
{
public int AggregateScorecardId { get; set; }
[Display(Name = "Measure")]
[Required]
public int MeasureId { get; set; }
...
public virtual Measure Measure { get; set; }
}
Measure Model
public partial class Measure
{
public Measure()
{
AggregateScorecard = new HashSet<AggregateScorecard>();
}
public int MeasureId { get; set; }
...
public virtual ICollection<AggregateScorecard> AggregateScorecard { get; set; }
}
SIGN IN To post a reply.
3 Replies
SK
Sujith Kumar Rajkumar
Syncfusion Team
March 27, 2020 10:02 AM UTC
Hi Sheldon,
Greetings from Syncfusion support.
Based on your query we could see that you are facing issue on using Include() method to process the data returned from SQL server. The LINQ Include() method has performance related issues which in some cases leads to value returning back from the controller but not getting displayed in the Grid. This is due to the process not getting completed by the Include() method due to the performance issues. So instead of using Include() we suggest you to use Join() LINQ property to resolve this issue. Please refer the below link discussing this issue for your reference,
Let us know if you have any concerns.
Regards,
Sujith R
SH
Sheldon
March 30, 2020 12:26 PM UTC
Thanks for the direction. Changed to OnPostLoadData to utilize join instead of include and works great.
public JsonResult OnPostLoadData([FromBody]DataManagerRequest dm)
{
IEnumerable scorecard = _context.AggregateScorecard
.Where(a => a.CurrentScorecard == true)
.Include(m => m.Measure) <-- This causes the grid to show no data, if commented out grid shows data
.OrderBy(a => a.Measure.Outcome.Aim.ItemOrder)
.ThenBy(a => a.Measure.Outcome.Outcome1)
.ThenByDescending(a => a.PeriodStart)
.ToList();
int count = _context.AggregateScorecard
.Where(a => a.CurrentScorecard == true)
.Count();
DataOperations operation = new DataOperations();
scorecard = operation.Execute(scorecard, dm);
return new JsonResult(new { result = scorecard, count = count }, new JsonSerializerSettings());
}
changed to
public JsonResult OnPostLoadData([FromBody]DataManagerRequest dm)
{
var scorecard = (from ag in _context.AggregateScorecard
join m in _context.Measure on ag.MeasureId equals m.MeasureId
join ...
where ag.CurrentScorecard == true
orderby a.ItemOrder
select new
{
ag.AggregateScorecardId,
ag.MeasureId,
...
}).ToList();
int count = _context.AggregateScorecard
.Where(a => a.CurrentScorecard == true)
.Count();
DataOperations operation = new DataOperations();
scorecard = operation.Execute(scorecard, dm);
return new JsonResult(new { result = scorecard, count = count }, new JsonSerializerSettings());
}
SK
Sujith Kumar Rajkumar
Syncfusion Team
March 31, 2020 05:29 AM UTC
Hi Sheldon,
We are glad to hear that your problem has been resolved. Please get back to us if you require further assistance.
Regards,
Sujith R
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
SH Sheldon
- Mar 26, 2020 02:30 PM UTC
- Mar 31, 2020 05:29 AM UTC