0

On a SharePoint 2010 Webpage need to search and display rows of information from an Excel sheet or List.

  1. Webpage should have pull down to select values viz. from 3 pull down combo boxes Year, Function and Partner.
  2. Now the values matching the combination of above search strings should either query an Excel sheet or SharePoint List and display data in a format as complemented with html tags of my choice.

Tools available to use are: SharePoint Designer 2010, Excel and Custom List.

Do not have access to code or deploy a .net package or file.

Need your help at the earliest.

  • Search functionality isn't available this way. You can create views that will allow you to filter though. – jpollar Jan 15 '17 at 2:14
0

If you have edit permission on your SharePoint 2010 WebPage, then you can add a CEWP in your page and display your content using java-script. Call a function on "Search" button using Rest API.

function ButtonClick()
{
    var yearStr = document.getElementById("ddlYear").value.toString().trim();
    var functionStr = document.getElementById("ddlFunction").value.toString().trim();
    var partnerStr = document.getElementById("ddlPartner").value.toString().trim();

    var count = 0;
    var yearFlag = false;
    var functionFlag = false;
    var partnerFlag = false;

    var url;

    if(yearStr.length > 0)
    {
        count++;
        yearFlag = true;
    }

    if(functionStr.length > 0)
    {
        count++;
        functionFlag = true;
    }

    if(partnerStr.length > 0)
    {
        count++;
        partnerFlag = true;
    }

    if(count == 3)
    {
        if(yearFlag == true && functionFlag == true && partnerFlag == true)
        {
            url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('ListName')/items?$filter=(Year eq " + yearStr + ") and (Function eq " + functionStr + ") and (Partner eq " + partnerStr + ")";
        }
    }   
    else if(count == 2)
    {
        if(yearFlag == true && functionFlag == true)
        {
            url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('ListName')/items?$filter=(Year eq " + yearStr + ") and (Function eq " + functionStr + ")";
        }       
        else if(functionFlag == true && partnerFlag == true)
        {
            url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('ListName')/items?$filter=(Function eq " + functionStr + ") and (Partner eq " + partnerStr + ")";
        }       
        else if(yearFlag == true && partnerFlag == true)
        {
            url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('ListName')/items?$filter=(Year eq " + yearStr + ") and (Partner eq " + partnerStr + ")";
        }
    }
    else if(count == 1)
    {
        if(yearFlag == true)
        {
            url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('ListName')/items?$filter=(Year eq " + yearStr + ")";
        }       
        else if(functionFlag && == true)
        {
            url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('ListName')/items?$filter=(Function eq " + functionStr + ")";
        }       
        else if(partnerFlag == true)
        {
            url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('ListName')/items?$filter=(Partner eq " + partnerStr + ")";
        }
    }


    $.getJSON(url, function(data) {    
        $(data.value).each(function(i,item){
            // code
        });
    });
}

Replace 'ListName' with your list name, and 'Year', 'Function' and 'Partner' are columns name replace them with yours.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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