组查询以获取特定订单

时间:2016-07-21 15:16:50

标签: c# sql asp.net-mvc sharepoint-2013

我使用此查询填充我的图库:

  function GalleryCatPopulate(url, listname, target) {

    var eng = false;
    if ((window.location.href.indexOf("lang=en") > 0)) {
        eng = true;
    }


    // Getting our list items
    $.ajax({
        url: url + "/_api/web/lists/getbytitle('" + listname + "')/items?$select=Title,English",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            completeGalleryCat(data, target, eng);
        },
        error: function (data) {
            failureGalleryCat(data, target);
        }
    });
}

function completeGalleryCat(data, target, eng) {
    var items = data.d.results;
    var prefix = "";
    var sufix = "<div class='clear'></div>";
    //if (eng)
     //  prefix = "<div class='filter selected' data-category='cat-all'>All</div>";
    //else
      //  prefix = "<div class='filter selected' data-category='cat-all'>Todas</div>";

    var menu = "";
    var cat = "";
    var title = "Transporte de Materiales";
    console.log(title.replace(/\s/g, "_").replace(/[^\w\s]/gi, ''));
    for (var item in items) {
        if (eng)
           cat = items[item].English; 
        else 
            cat = items[item].Title;

                  menu += "<div class='filter' data-category='" + cat.replace(/\s/g, "_").replace(/[^\w\s]/gi, '') +"'>"+ cat +"</div>";

            }
    $(target).html(prefix + menu + sufix);

}

function failureGalleryCat(data, target) {
    $(target).text("Ocurrió un error en la carga las categorias. Por favor revise la consola para más información");
}

function GalleryContentPopulate(url, listname, target) {

    var eng = false;
    var queryGallery = "$select=Title,Description,Enlace,EncodedAbsUrl,Categoria/Title&$expand=Categoria/Title$SortField=Title&SortDir=Desc";

    if ((window.location.href.indexOf("lang=en") > 0)) {
        queryGallery = "$select=TitleEnglish,DescriptionEnglish,Enlace,EncodedAbsUrl,Categoria/English&$expand=Categoria/English";
        eng = true;
    }


   // Getting our list items
$.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);
}
});
}
function completeGalleryContent(data, target, eng) {
    var items = data.d.results;
    //console.log(items);
    var menu = "";
    var cat = "";
    for (var item in items) {
    if(items[item].DescriptionEnglish==null)
        items[item].DescriptionEnglish="";
    if(items[item].Description==null)
        items[item].Description="";
        if(items[item].Categoria.results!= null && items[item].Categoria.results!= undefined && items[item].Categoria.results.length > 0){
            cat =setCategories(eng,items[item].Categoria.results);
        }
        if (eng){
            //menu += "<div class='mega-entry " + cat + " cat-all' id='mega-entry-1' data-src='" + items[item].EncodedAbsUrl + "' data-width='' data-height='' data-lowsize=''><div class='mega-covercaption mega-square-bottom mega-landscape-right mega-portrait-bottom mega-red'><div class='mega-title'>" + items[item].TitleEnglish + "</div><p>" + items[item].DescriptionEnglish + "</p></div><div class='mega-coverbuttons'><div class='mega-link mega-red'></div><a class=' ' rel='group' href='" + items[item].EncodedAbsUrl + "' title='" + items[item].TitleEnglish + "'><div class='mega-view mega-red'></div></a></div></div>";

            menu += "<div class='mega-entry " + cat + " cat-all' id='mega-entry-1' data-src='" + items[item].EncodedAbsUrl + "' data-width='' data-height='' data-lowsize=''><div class='mega-covercaption mega-square-bottom mega-landscape-right mega-portrait-bottom mega-red'><div class='mega-title'>" + items[item].TitleEnglish + "</div><p>" + items[item].DescriptionEnglish + "</p></div><div class='mega-coverbuttons'><a class=' ' rel='group' href='" + items[item].EncodedAbsUrl + "' title='" + items[item].TitleEnglish + "'><div class='mega-view mega-red'></div></a></div></div>";
        }else{
         //menu += "<div class='mega-entry "+ cat + " cat-all' id='mega-entry-1' data-src='" + items[item].EncodedAbsUrl + "' data-width='' data-height='' data-lowsize=''><div class='mega-covercaption mega-square-bottom mega-landscape-right mega-portrait-bottom mega-red'><div class='mega-title'>" + items[item].Title + "</div><p>" + items[item].Description + "</p></div><div class='mega-coverbuttons'><div class='mega-link mega-red'></div><a class='fancybox' rel='group' href='" + items[item].EncodedAbsUrl + "' title='"+ items[item].Title +"'><div class='mega-view mega-red'></div></a></div></div>";

          menu += "<div class='mega-entry "+ cat + " cat-all' id='mega-entry-1' data-src='" + items[item].EncodedAbsUrl + "' data-width='' data-height='' data-lowsize=''><div class='mega-covercaption mega-square-bottom mega-landscape-right mega-portrait-bottom mega-red'><div class='mega-title'>" + items[item].Title + "</div><p>" + items[item].Description + "</p></div><div class='mega-coverbuttons'><a class='fancybox' rel='group' href='" + items[item].EncodedAbsUrl + "' title='"+ items[item].Title +"'><div class='mega-view mega-red'></div></a></div></div>";
        }
    } 
    $(target).html(menu);
      var api = $(target).megafoliopro(
                   {
                       filterChangeAnimation: "pagebottom",         // fade, rotate, scale, rotatescale, pagetop, pagebottom,pagemiddle
                       filterChangeSpeed: 400,                  // Speed of Transition
                       filterChangeRotate: 99,                  // If you ue scalerotate or rotate you can set the rotation (99 = random !!)
                       filterChangeScale: 0.6,                  // Scale Animation Endparameter
                       delay: 20,
                       defaultWidth: 980,
                       paddingHorizontal: 10,
                       paddingVertical: 10,
                       layoutarray: [9, 11, 5, 3, 7, 12, 4, 6, 13]      // Defines the Layout Types which can be used in the Gallery. 2-9 or "random". You can define more than one, like {5,2,6,4} where the first items will be orderd in layout 5, the next comming items in layout 2, the next comming items in layout 6 etc... You can use also simple {9} then all item ordered in Layout 9 type.
                   });

            //console.log("entra");
            // FANCY BOX ( LIVE BOX) WITH MEDIA SUPPORT


            //console.log("sale");

            // THE FILTER FUNCTION
            $('.filter').click(function () {
                $('.filter').each(function () { jQuery(this).removeClass("selected") });
                api.megafilter(jQuery(this).data('category'));
                $(this).addClass("selected");
            });
   var categorySelected = getParameterByName("Category");
  //  $('[data-category="Office"],[data-category="Oficinas"]').click();

  // Aquí agarramos la primera categoria
     $(".filter").eq(0).trigger("click");
    $("div[data-category='"+categorySelected +"']").click();
     jQuery(".fancybox").fancybox();

}
function failureGalleryContent(data, target) {
   // console.log(data);
    $(target).text("Ocurrió un error en la carga la sección parallax. Por favor revise la consola para más información");
}


function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

function setCategories(boolLang, objResult){
var cat ="";
    for(var item in objResult){
     if(boolLang)
        cat += replaceAll(" ", "_",objResult[item].English.replace(/[^\w\s]/gi, '')) + ' ';
     else
        cat += replaceAll(" ", "_",objResult[item].Title.replace(/[^\w\s]/gi, '')) + ' ';
    }
    return cat;
}

function replaceAll( find, replace,string) {
  return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
function escapeRegExp(string) {
    return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}

问题在于我不知道为什么先拍摄每个类别的一张图像然后获取一个类别的所有图像,例如 我有这个类别

服务,家庭,办公室

在我获得的第一行图片中:

firstimageServices
firstimageHome
firstimageOffice
secondimageOffice
thirdimageOffice
etc... 

但是我想按类别分组,所以它将是:

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

如何在查询中对其进行分组?此致!

注意:我对这些链接msdn感兴趣但是如何在我的查询中应用它来按“标题”排序

所以在第一个领域,我得到类似的东西: enter image description here

当它传递第一行类别时,我得到了我想要的那些: enter image description here

1 个答案:

答案 0 :(得分:0)

我最后只是更改查询:

"$select=Title,Description,Enlace,EncodedAbsUrl,Categoria/Title&$expand=Categor‌​i‌​a/Title&$orderby=Title asc";