Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom template with DisplayTemplate and full path not working #71

Open
toregua opened this issue Feb 19, 2018 · 1 comment
Open

Custom template with DisplayTemplate and full path not working #71

toregua opened this issue Feb 19, 2018 · 1 comment

Comments

@toregua
Copy link

toregua commented Feb 19, 2018

First thank you very much for your nice component :)

In my project i need to specify the full path of my template but when i use a path like :
~/Areas/SiteWeb/Views/Shared/_MyTemplate.cshtml it is not working because in your component in Pager.cs you force the template to be in the Displaytemplates folder like this :
var templatePath = string.Format("DisplayTemplates/{0}", this.pagerOptions.DisplayTemplate);

I suggest to check if this.pagerOptions.DisplayTemplate start with ~ in order to use full path like this for example :

if (!String.IsNullOrEmpty(this.pagerOptions.DisplayTemplate))
{
	var templatePath = String.empty;
	if(this.pagerOptions.DisplayTemplate.StartsWith("~")){
		templatePath = this.pagerOptions.DisplayTemplate;
	}
	else{
		templatePath = string.Format("DisplayTemplates/{0}", this.pagerOptions.DisplayTemplate);
	}
	return htmlHelper.Partial(templatePath, model).ToHtmlString();
}

It will be more flexible for people who have my needs.

Thank you in advance

@martijnboland
Copy link
Owner

martijnboland commented Feb 19, 2018

Good idea. Could you perhaps create a pull request for this since you've already figured out the solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants