I'd like to filter SharEPoint list using values from another list via JS Link. I know how to filter using for example list of ID's. I found nice article for that but now I need firstly to connect to another list then find relevant item and take value from relevant column to use it as a filter. For filtering I use the following function:
(function () {
var excludeRows = [0,2,3];
function renderListItemTemplate(renderCtx) {
if(excludeRows.indexOf(renderCtx.CurrentItemIdx) > -1)
{
return ''; //do not render row
}
return RenderItemTemplate(renderCtx);
}
function registerListRenderer()
{
var context = {};
context.Templates = {};
context.Templates.Item = renderListItemTemplate;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(context);
}
ExecuteOrDelayUntilScriptLoaded(registerListRenderer, 'clienttemplates.js');
})()
As I mentioned it works for me. Now I'd like to retrieve some data from another list to filter this list. I try to use SP.ClientContext() ... firstly but it doesn't work for me. I suppose problem with code structure or maybe I have to load any library before. I have no idea how to do it correctly. Maybe another idea would be useful?
I thought about calculated columns but I don't think so it would be useful for me. Ok maybe I will explain my idea more deeply. I'm developing complex solution (not based only on the SharePoint) where displaying relevant items from the list is only small part of the system. Let's imagine we have two lists: Workers and Resources. In the Workers list I have column which contains IDs of the Resources. For example:
Workers List:
Username -> IDs
John -> 1,4,7,9
Bill -> 2,7.8
Resoures List:
ID -> Name
1 -> Aplication X
2 -> Aplication Y
....
and now I'd like to create a page where user would be able to see resources where has access to. My idea is to filter Resources List and show only relevant resources. First of all I have to recognize the user (I suppose it is not difficult) next find user in the workers List, take data from IDs column and use it to filter Resources List. I know how to filter (see example in my main post) but I need your advise how to connect to Workers list to get IDs. I decide to use JS Link but maybe there is another better solution I hope it is clear right now.