Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

jslink issues with multiple list views

$
0
0

Hello Techies,

I am stuck with jslink issues.

I have a list with various columns say BRDDate, KickOFFDate and Status.
Note: There are other date columns for the list.

Status column has options :

BRD Received
Kicked Off
In discussion

I need to create a KPI sort of multiple list views on a single page.

I created one list view say BRD and based on that change the KPI images
Here is the code:
For this list view i applied filter for Status equals BRD Received and In discussion

(function() {

	var statusFieldCtxBRD= {};
	statusFieldCtxBRD.Templates = {};
	statusFieldCtxBRD.BaseViewID = 1;
  	statusFieldCtxBRD.ListTemplateType = 100;
  	statusFieldCtxBRD.ViewId='B0D1020C-CDFB-4F76-8A1A-8AF8F2283746';


	statusFieldCtxBRD.Templates.Fields = {"KPI": {"View":StatusIconViewTemplateBRD}};


SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtxBRD);

})();

function StatusIconViewTemplateBRD(ctx) {
//debugger;
	var _statusValue = ctx.CurrentItem["Status"];
	var brdreceivedDate=ctx.CurrentItem["BRD_x0020_Received"];
	//var_dueDate = new Date(ctx.CurrentItem.DueDate);
	//alert("BRD: "+brdreceivedDate);
	alert('BRD script');
	var now = new Date();
	now=(now.getDate() + '-' +now.getMonth() + 1) + '-' +  now.getFullYear();

	//alert("HELLO");
	if(ctx.wpq=='WPQ3')
	{

			if(brdreceivedDate =='')
			{
				return '';

			}
			else if(brdreceivedDate==now || brdreceivedDate<now)
			{
				return "<img width='40' height='40' src='/imisscpl/dw/SiteAssets/green.png'";
			}
			else
			{
				return "<img width='40' height='40' src='/imisscpl/dw/SiteAssets/red.png'";
			}
	}
}


Here is the issue, I created another list view for kickOff date and here is the jslink code:
For this list view i applied filter for Status equals Kicked Off

(function() {

	var statusFieldKickOffCtx = {};
	statusFieldKickOffCtx.Templates = {};
	statusFieldKickOffCtx.BaseViewID =1;
  	statusFieldKickOffCtx.ListTemplateType = 100;
  	statusFieldKickOffCtx.ViewId='b058c8e2-07eb-4c1c-842e-8ecc8f24ac0c';

	statusFieldKickOffCtx.Templates.Fields = {"KPI": {"View":StatusIconViewTemplatekickOff}};

	SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldKickOffCtx);

})();

function StatusIconViewTemplatekickOff(ctx)
	{
		//debugger;
		alert('kickOff script');
		var _statusValue = ctx.CurrentItem["Status"];
		var kickOffDate = ctx.CurrentItem["KickOff"];
		//var_dueDate = new Date(ctx.CurrentItem.DueDate);
		//alert("BRD: "+kickOffDate);

		var now = new Date();
		now=(now.getDate() + '-' +now.getMonth() + 1) + '-' +  now.getFullYear();
		if(ctx.wpq=='WPQ4')
		{
			if(kickOffDate=='')
			{
				return '';
			}
			else if(kickOffDate==now || kickOffDate < now)
			{
				return "<img width='40' height='40' src='/imisscpl/dw/SiteAssets/green.png'";
			}
			else
			{
				return "<img width='40' height='40' src='/imisscpl/dw/SiteAssets/red.png'";
			}
		}
	}

Jslink for a single list view is working fine but it not working for multiple list views.

I tried giving list viewIDs and ctx.wpq in the jslink code but nothing works here.

Please let me know where i am going wrong


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>