How to set containerId when I call Highsoft().Highcharts - model-view-controller

I'am trying to use Highchart in my MVC project.
I set containerId name for placing chart on the page, using next code:
#model MyProjectModel
#using Highsoft.Web.Mvc.Charts;
...
for (int i = 0; i < Model.Machines.Count; i++)
{
<div id="#Model.Machines[i].containerName"></div>
#(Html.Highsoft().Highcharts(
new Highcharts ({...}, Model.Machines[i]);
}
and Chart don't place in div
but then I set containerId next way
...
new Highcharts({...}, "container");
...
It's ok.
How I can set containerId in code?
Thank's for help

Perhaps I'm wrong, but why the div id is set as id="#Model.Machines[i].containerName" and then you are passing just Model.Machines[i] to Highcharts constructor? Try to provide the containerName:
#model MyProjectModel
#using Highsoft.Web.Mvc.Charts;
...
for (int i = 0; i < Model.Machines.Count; i++)
{
<div id="#Model.Machines[i].containerName"></div>
#(Html.Highsoft().Highcharts(
new Highcharts ({...}, Model.Machines[i].containerName);
}

Related

use Dojo to add an onclick event for a series of img

A button is clicked to trigger LoadImages method to load a series of pictures into the web page. I want to add an onclick event for each picture so when user click it, the picture name is displayed. How to use Dojo to achieve this?
LoadImages(PictureNames){
var resultUl = new Builder('<ul />');
for (i = 0; i < PictureNames.length; i++){
resultUl.append('<li><img id=' + PictureNames[i] + ' src="./images/' + PictureNames[i] + '.jpg" height="200" width="250" class="photo"/></li>');
}
dom.byId('Pictures').innerHTML = resultUl;
}
DisplayPictureName(picturename)
{
dom.byId('PictureName').value = picturename;
}
<label id="PictureName">here displays picture name</label>
<div id="Pictures"></div>
Make the elements using dojo/dom-construct and attach events using dojo/on.
var resultUl = domConstruct.create('ul');
for (i = 0; i < PictureNames.length; i++){
var image= domConstruct.create('img', {
id: PictureNames[i]',
src: "./images/"+ PictureNames[i],
style: {"height: 200px; width: 250px"},
class: "photo"});
var li= domConstruct.create('li');
domConstruct.place(li, resultUl);
domConstruct.place(image, li);
dojo.on(image, 'click', this.DisplayPictureName());
}
dom.byId('Pictures').innerHTML = resultUl;

YUI 2.9 TreeView

I am able to render a tree using YAHOO.widget.TreeView yui 2.9.
Using pre made tags
<ul> <li> Products </li> </ul>
I am able to get the label i.e Products using node.label
YAHOO.util.Event.on('allProductSaveButton','click',function() {
var hiLit = rightProductTree.getNodesByProperty('highlightState',1);
if (YAHOO.lang.isNull(hiLit)) {
YAHOO.log("None selected");
} else {
var labels = [];
for (var i = 0; i < hiLit.length; i++) {
var node = hiLit[i];
if(node.children.length<=0) {
labels.push(hiLit[i].label); }
}
alert("Highlighted nodes:\n" + labels.join("\n"), "info", "example");
}
});
I want to insert id of the Products in the html and get the id of label as well. so where should I place id attribute inside or where?
I am not sure you can set your own id on the markup. TreeView is one of the oldest widgets in YUI 2 and it uses a particularly funny markup because the supported CSS styles in those days were quite pathetic, thus, what part of that funny markup are you going to apply that id to?
If what you want is to give a tree-node an identifier that you can later use to retrieve it, then use custom properties. Then, calling getNodesByProperty will allow you to retrieve the node by the value of that extra property.
I got a solution. I inserted the label element inside the span element that was inside the li element i.e
<ul>
<li> <span> <label id="444" > Product </label> </span>
</li>
</ul>
then using YAHOO.util.Dom I traversed and got the id attribute of label element.
YAHOO.util.Event.on('GroupsProductSaveButton', 'click', function() {
var hiLit = rightProductTree2.getNodesByProperty('highlightState', 1);
if (YAHOO.lang.isNull(hiLit)) {
alert("None selected");
} else {
var labels = [];
for (var i = 0; i < hiLit.length; i++) {
var node = hiLit[i];
if(node.children.length<=0) {
labels.push(YAHOO.util.Dom.get(hiLit[i].contentElId).getElementsByTagName('label')[0].getAttribute("value")); }
}
alert("Highlighted nodes:\n" + labels.join("\n"), "info", "example");
ProductGroupDWR.displaySelectedNodes(labels, function(data) {
});
}
});

firefox js getSVGDocument().getElementsByClassName('myClass') broken?

i have an embedded SVG, using js to change 20 path fill colors, all having the same class.
<script>
function svgMod(){
//var links = document.getElementById("tornado5").getSVGDocument().
// getElementsByClassName('SVGlogo');
var links = document.getElementById("tornado5").contentDocument.
getElementsByClassName('SVGlogo');
for (var i=0;i<links.length;i++) { links[i].style.fill="00ff00"; }
}
</script>
<object type="image/svg+xml" id="tornado5" data="bitmaps/frames/tornado2.svg">
</object> <!-- cant use img -->
<button onclick="svgMod();" >Click to change</button>
It works in Chrome, but not firefox.
ive tried both contentDocument and getSVGDocument(), but no help. links.length is 20, even in firefox, so the problem seems to be in links[i].style.fill
any ideas?
Can you try changing this line:
for (var i=0;i<links.length;i++) { links[i].style.fill="00ff00"; }
to this:
for (var i=0; i < links.length; i++) {
links[i].setAttribute("fill", "#00ff00");
}
OR
for (var i=0; i < links.length; i++) {
links[i].style.fill = "#00ff00";
}
Hope this helps.

How to make the tab get focus

In my gridComplete function, depending on certain values in the datarow, I want to move the focus to a different tab. The gridCompelete function will be something like
var grid = $('#grdResults');
var m = grid.getDataIDs();
for (var i = 0; i < m.length; i++) {
var rowData = grid.getRowData(m[i]);
if (rowData.errorMessage != '') {
alert(rowData.errorMessage);
$('#UploadMain').focus();
}
}
Obviously the .focus() does not seem to work. Given below is the part of the view that has the code for the tabs
<div id="editTabs">
<ul>
<li>Main</li>
<li>Data Validation</li>
</ul>
<div id="UploadMain">
<fieldset>
.......
What do I need to have the focus moved?
Are you looking for the select() method?
$("#editTabs").tabs("select", 0); // Activate first tab.
Or:
$("#editTabs").tabs("select", "#UploadMain"); // Activate "UploadMain" tab.

images and selectbox in jqgrid

hai i am very new to jquery and jqgrid..
i have implemented a grid...but i don't have any idea to display images in column from the corresponding database value...i tried a lot but failed ..can anybody help me..
regards
In the setup parameters add:
loadComplete: function() {
var ids = $("#list").getDataIDs();
for (var i = 0; i < ids.length; i++) {
var cl = ids[i];
be = "<img src='http://www.google.com/images/nav_logo6.png'>";
$("#list").setRowData(ids[i], { externalId: be })
}
},
In this example it will load the google logo. This sample goes over all the rows and adds the same item. You can change it do be more dynamic based on the current value of the cell etc.

Resources