I want the same column display different title in different views with only one list.
So I append a jquery script in my view.aspx.
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script type="text/javascript" src="/_layouts/15/Library/js/jquery-1.9.1.js"> </script>
<script type="text/javascript">
$(document).ready(function(){
$('[id^=diidSort][id$=company]').text('com');
});
</script>
It works,but when I click column ascending or descending then refresh page. the column
title restore to original text. How could I fix it?
Since it is a SharePoint 2013 environment, the following approach is suggested:
Create rendering template in order to render the custom column title
in a List View
Update List View web part in View page
Template file
SharePoint 2013 introduces client side rendering framework (CSR) for List View that allows to define the rendering logic of SharePoint list views using HTML/JavaScript.
The following example demonstrates how to render the custom title for Title column in List View:
(function () {
function preTaskFormRenderer(renderCtx) {
modifyHeaderData(renderCtx);
}
function modifyHeaderData(renderCtx)
{
var viewTitle = renderCtx.viewTitle;
var linkTitleField = renderCtx.ListSchema.Field[1];
linkTitleField.DisplayName = viewTitle + ':' + linkTitleField.DisplayName;
}
function registerRenderer()
{
var ctxForm = {};
ctxForm.Templates = {};
ctxForm.OnPreRender = preTaskFormRenderer;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(ctxForm);
}
ExecuteOrDelayUntilScriptLoaded(registerRenderer, 'clienttemplates.js');
})();
How to apply changes
Upload the specified script (lets name it TaskForm.js) into
SharePoint Site Assets library
Open View page in edit mode and go to List View web part properties
Specify JS Link property located under Miscellaneous group:
~sitecollection/SiteAssets/TaskForm.js (see pic. 1)
Save changes and repeat steps 2-4 for every View page if needed
Fig 1. JS Link property
Result
Related
I am new to ember and I am trying to figure how to show different model hooks on a component. I have two models that I want to show in a table. Each model should show when the link-to route is clicked, but I want to use one component to build the table like so
let newCol = [];
export default Component.extend({
table:null,
model:null,
columns:computed(()=>{
return newCol;
}),
init(){
this._super(...arguments)
let model = this.get('model')
for(const key of Object.keys(model[0])){
newCol.push({'label': key});
newCol.push({'valuePath': key});
//console.log(key)
}
let table = new Table(this.get('columns'),this.get('model'));
//console.log('table = ', table);
this.set('table',table);
}
});
I am passing all my model hook from my routes like this
{{client-main-table model=model}}
and my menu is created like this
{{#each menu as |menu|}}
<li>{{#link-to menu}}{{capitalize menu}}{{/link-to}}</li>
{{/each}}
this creates a menu like user, files
when I click the user menu it display the users data on the table but if when I click the files menu then the table doesn't reset to show just the files data. It shows the user and the files data.
Did you know how to create dropdown with tooltip in sharepoint form?
Could you please suggest me best way to accomplish this functionality.
Thanks.
We can use jQuery code to achieve it, add the code below into a script editor web part in the new/edit form page.
<script src="//code.jquery.com/jquery-1.12.4.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var fieldname="PC Model Required Field";// modify the fieldname
$("select[title='"+fieldname+"'] option").each(function(){
$(this).attr("title",$(this).val());
});
});
</script>
I just got finished implementing the solution from this question on a similar topic, but the solution is not working for me.
I'm trying to create a dashboard that uses data from a google spreadsheet but I can't seem to get it to load correctly.
I routinely get the following error message whenever I load the web page:
One or more participants failed to draw()
Here's the code I'm using right now:
<html>
<head>
<script type="text/javascript">
// Load the Visualization API and the controls package.
google.charts.load('current', {'packages':['corechart', 'controls']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(initialize);
function initialize() {
var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1FnETUo8yrthFBdUYsQ8Ty9e8pK3ouWZntvDnXlhHKws/edit#gid=0');
query.send(drawDashboard)
}
// Callback that creates and populates a data table,
// instantiates a dashboard, a range slider and a pie chart,
// passes in the data and draws it.
function drawDashboard(response) {
// Create our data table.
var data = response.getDataTable();
// Create a dashboard.
var dashboard = new google.visualization.Dashboard(
document.getElementById('dashboard_div'));
// Create a range slider, passing some options
var donutRangeSlider = new google.visualization.ControlWrapper({
'controlType': 'NumberRangeFilter',
'containerId': 'filter_div',
'options': {
'filterColumnLabel': 'Donuts eaten'
}
});
// Create a pie chart, passing some options
var pieChart = new google.visualization.ChartWrapper({
'chartType': 'PieChart',
'containerId': 'chart_div',
'options': {
'width': 300,
'height': 300,
'pieSliceText': 'value',
'legend': 'right'
}
});
// Establish dependencies, declaring that 'filter' drives 'pieChart',
// so that the pie chart will only display entries that are let through
// given the chosen slider range.
dashboard.bind(donutRangeSlider, pieChart);
// Draw the dashboard.
dashboard.draw(data);
}
</script>
</head>
<body>
<div id="dashboard_div">
<!--Divs that will hold each control and chart-->
<div id="filter_div"></div>
<div id="chart_div"></div>
</div>
</body>
</html>
Link to the spreadsheet can be seen here: https://docs.google.com/spreadsheets/d/1FnETUo8yrthFBdUYsQ8Ty9e8pK3ouWZntvDnXlhHKws/edit#gid=420659822
The dashboard I'm trying to draw is taken directly from the source documentation listed here: https://developers.google.com/chart/interactive/docs/gallery/controls
I'm trying to follow the example about loading external spreadsheets here: https://developers.google.com/chart/interactive/docs/spreadsheets
The link to the working file I'm using for this project can be seen here: https://s3-us-west-2.amazonaws.com/example-server/index.html
I've tried removing all header links and styling in the previous link to verify nothing else was interfering with the visualization API and this did not solve the problem either.
Also:
Privacy for the spreadsheet is set to 'Public on the web'
The link being used in the query is taken directly from the address bar, but I also used the 'sharing link' provided by google when you prompt for it.
I'm using data that's exactly the same as the examples in the google documentation to make implementation as easily as possible.
Edit
Due to an answerer's prompt, I experiemented with different modifications of my query URL, which so far have not worked.
Here's the URL in my address bar:
URL
It's a single sheet document.
In response to the first answer, I've tried the following query URL's, but without success.
First:
https://docs.google.com/spreadsheets/d/1FnETUo8yrthFBdUYsQ8Ty9e8pK3ouWZntvDnXlhHKws/gviz/tq?sheet=Sheet1
Second:
https://docs.google.com/spreadsheets/d/1FnETUo8yrthFBdUYsQ8Ty9e8pK3ouWZntvDnXlhHKws/gviz/tq?gid=0
Third:
https://docs.google.com/spreadsheets/d/1FnETUo8yrthFBdUYsQ8Ty9e8pK3ouWZntvDnXlhHKws/gviz/tq?gid=1FnETUo8yrthFBdUYsQ8Ty9e8pK3ouWZntvDnXlhHKws
The idea behind this last URL is that in the new google sheets the gid is the string after d/ and before /edit.
Your help is greatly appreciated.
Find your dataSourceURL at:
var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1FnETUo8yrthFBdUYsQ8Ty9e8pK3ouWZntvDnXlhHKws/edit#gid=0');
Replace:
edit#gid=0
with:
gviz/tq?sheet=Sheet1
If that doesn't work, then you'll need to use the gid which is a unique 9 to 10 digit number. (ex. gid=1104711743). Open your sheet and look at the address bar, you should see it at the end of the url.
Your line should look like this:
var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1FnETUo8yrthFBdUYsQ8Ty9e8pK3ouWZntvDnXlhHKws/gviz/tq?gid=1234567890');
Currently I have following JavaScript in my filter.tpl file. This has hidden the refined search button and filters product on checkbox click. But It loads the whole page on a check box click. I want to implement AJAX loader so that only the page loads partially.
<script type="text/javascript"><!--
$(document).ready(function() {
$('#button-filter').hide();
$('input[name^=\'filter\']').on('change', function() {
filter = [];
$('input[name^=\'filter\']:checked').each(function(element) {
filter.push(this.value);
});
location = '<?php echo $action; ?>&filter=' + filter.join(',');
});
});
//--></script>
I am working on Sitecore MVC controller. I have created a controller “EventController” that have two actions “AllEvents” and [HttpPost] “SelectedYear” , one view “\Views\Event\AllEvents.cshtml”
“AllEvents” is attached with Sitecore controller rendering when I do publish preview from the content item page is loading with data and there is no problem. “All Events” page have a dropdown
When I click on selected year the post back is going but the view is not loading as required and losing the RenderingContext also. The url is going to hit http://testPage/api/Event/SelectedYear and image and css are not loading but data is there.
Below I have shared the sample code.
Please help me to fix the issue.
AllEvents.cshtml
<div>
#using (Html.BeginForm("SelectedYear", "Event", FormMethod.Post, new { id = "TheForm"}))
{
#Html.DropDownListFor(model => model.SelectedYear, Model.mapLocationItemTypes, "-- Select Status --", new { id = "CategoryID" })
}
</div>
SelectedYear Action
[HttpPost]
public ActionResult SelectedYear()
return View(eventCalender);
<script type="text/javascript">
$(function () {
alert("HSecond")
$("#CategoryID").change(function () {
$('#TheForm').submit();
});
});
</script>
RouteConfig
routes.MapRoute(
name: "Default",
url: "api/{controller}/{action}/{id}",
defaults: new { controller = "home", action = "index", id = UrlParameter.Optional }
In your Html.BeginForm() you specify the controller and the action to post to. But in fact, you want to post to the same Url, load the same Item and call the [HttpPost] action instead. This is a little different between ASP.net MVC and Sitecore MVC. I've written a blog post on how to handle form posts with Sitecore MVC:
http://ctor.io/posting-forms-in-sitecore-controller-renderings-another-perspective/
Also I had a presentation about Sitecore MVC at the SUGCON this year where posting forms was a topic. You may also want to look at the slides or the screencast