CSR - Based on a dynamic filter - Append string to the Column values for display

Hello All SharePoint Gurus - I have a scenario where i need to select a value from dropdown and based on the value i need to append the string to a column for display. Is this possible via CSR? For a dropdown I could either a simple html dropdown or can use a filter webpart and set the connection to the list view webpart. Is it possible to append the string to a column of the list view webpart? Would I be able to preserve the list view functionality of search, sort and paging using csr?

Re

August 17th, 2015 2:46pm

Hi Khushi,

We can use Client-side rendering(JS Link) to achieve it in SharePoint 2013, get the dropdown value using jQuery code and append it to column. The code like this:

(function () {
    // jQuery library is required in this sample 
    // Fallback to loading jQuery from a CDN path if the local is unavailable 
    (window.jQuery || document.write('<script src="//ajax.aspnetcdn.com/ajax/jquery/jquery-1.10.0.min.js"><\/script>')); 
	
	// Create object that have the context information about the field that we want to change it's output render  
	var fieldContext = {};
	fieldContext.Templates = {};
	fieldContext.Templates.Fields = {
		"ColumnName": { "View": fieldTemplate }
	};
	SPClientTemplates.TemplateManager.RegisterTemplateOverrides(fieldContext);
})();

function fieldTemplate(ctx) {

    var htmlStr ="";
	
    //get the dropdown value using jQuery and append to the column
	//your code
    return htmlStr;
}

Here are some code samples for your reference:

https://code.msdn.microsoft.com/office/Client-side-rendering-JS-2ed3538a

Best Regards

Free Windows Admin Tool Kit Click here and download it now
August 19th, 2015 9:06am

Thank you Dennis. Really appreciate your response. I checked those examples. I couldn't find any example or lead that shows how to call the template render on certain event. for example in my case on dropdown change event, I want to render the page again depending on the dropdown selection. All example shows how to manipulate data for display when page render first. 

Patrick - Just to let you know that Dennis's response didn't answer my question. Not sure if you would like to open this question again for discussion.

Regards,

August 25th, 2015 3:56pm

Hi Khushi,

If you only want to append the string from a dropdown to a column of the list view webpart, we can use jQuery change event and some JavaScript code to achieve it.

If you want to filter list view base on a dropdown list value, here is a solution from codeplex for your reference:

https://splistviewfilter.codeplex.com/

Best Regards,

Dennis

Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 9:13pm

Hi Khushi,

Any update?

Thanks

August 29th, 2015 10:44pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics