0

I use this query to populate my gallery:

  var queryGallery = "$select=Title,Description,Enlace,EncodedAbsUrl,Categoria/Title&$expand=Categoria/Title";


$.ajax({
url: url + "/_api/web/lists/getbytitle('" + listname + "')/items?$top=1000&" + queryGallery, 
//url: url + "/_api/web/lists/getbycategory('Office'),

method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
    completeGalleryContent(data, target, eng);
},
error: function (data) {
    failureGalleryContent(data, target);
}
});
}

The problem is that I don´t know why first take one image of each category and after that get all images of one categorie, for example I have this categories

Services, Home, Office

In my first row of images I get:

firstimageServices
firstimageHome
firstimageOffice
secondimageOffice
thirdimageOffice
etc... 

But I want to group all by categorie, so it will be:

firstimageServices
secondimageServices
thirdimageServices
fourimageServices
etc...
firstimageHome
secondimageHome
thirdimageHome
fourimageHome
etc...
firstimageOffice
secondimageOffice
thirdimageOffice
fourimageOffice
etc..

How can I do in my query to group it? Regards!

Note: I look something of interest in these link msdn but how can I apply it in my query to sort by "Categoria"

2
  • Add $orderby=Categoria,Title asc to queryGallery? Commented Jul 21, 2016 at 15:36
  • It don´t works, I add it likevar queryGallery = "$select=Title,Description,Enlace,EncodedAbsUrl,Categoria/Title&$expand=Categoria/Title$orderby=Categoria,Title asc"; but It don´t pass to data, I review my question and I need to sort by Title so I do that: "$select=Title,Description,Enlace,EncodedAbsUrl,Categoria/Title&$expand=Categoria/Title$orderby=Title asc";` but don´t works too@EricAlexander
    – Gerry
    Commented Jul 21, 2016 at 15:59

1 Answer 1

0

You should add a '&$', not just '$' before the orderby clause, like this:

"$select=Title,Description,Enlace,EncodedAbsUrl,Categoria/Title&$expand=Categori‌​a/Title&$orderby=Categoria,Title asc";
1
  • Yes it works, you´re boss!!!!!!! but I only need to orderby Title so my answer is: "$select=Title,Description,Enlace,EncodedAbsUrl,Categoria/Title&$expand=Categori‌​a/Title&$orderby=Title asc";
    – Gerry
    Commented Jul 21, 2016 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.