Tuesday, 27 August 2013

How to sort a Json array c#

How to sort a Json array c#

I've got a time problem. And although I have a project on autonomous
because one of our developers has failed. The Project was implemented in C
# Asp.Net MVC. And I have actually not as much to do with it since I'm
actually rather responsible for Mobiele applications. And then I have
found the solution always on the look but I'm just simply not on.
And it is so we call on to get data from the database and pass it to a
jqgrid. I know this because there are probably problems with the General
Order. But I am now only at times between a solution. I want to sort the
arry issue and indeed descending.
ah yes sorry for the bad english.
find attached the code from the controller:
enter code here public class KalkulationController : BaseController
{
private IOrderedEnumerable<KalkulationMasterModel> array;
#region JSON
public virtual ActionResult List( string sidx, string sord, int page,
int rows, decimal? anr)
{
if (!anr.HasValue)
return null;
var service = new KalkulationMasterService();
var listOfKalkulation = service.GetListOfKalkulation(anr, Nutzer);
// array = listOfKalkulation.OrderByDescending(c => c);
var jsonData = new
{
total = 0,
page = page,
records = 10,
rows = (
listOfKalkulation.Select(k => new
{
i
=
k.AuftragId,
//

k.OrderBy(k
=>
k.Id);
cell
=
new
string[]
{
k.Id.ToString(),
k.AuftragId.HasValue?k.AuftragId.Value.ToString():null,
k.Bestellnummer.HasValue?k.Bestellnummer.Value.ToString():null,
k.NumberOfArt.HasValue?k.NumberOfArt.Value.ToString():null,
k.LT.HasValue
?
k.LT.Value.ToString()
:
null,
k.AAStatus??string.Empty,
k.Los.ToString(),
//k.Einheit,
//String.Format("{0:0.00}",k.Gesamtgewicht),
//String.Format("{0:0.00}",k.Preis),
String.Format("{0:0.00}",k.KundenPreis),
String.Format("{0:0.00}",k.KorekturPreis),
k.ArtikelNr.ToString()
}
})).ToArray()
};
return Json(jsonData, JsonRequestBehavior.AllowGet);

No comments:

Post a Comment