When the user has finished drawing polygons, the polygon label will be update with the calculated area.
polygonLayer.styleMap.styles.default.defaultStyle.label = "xxx";
polygonLayer.redraw();
which will achieve this, no problem.
I call this two lines everytime the area of the polygon is updated. However, if I edit the polygon with edit control, the updated area will be displayed on all the nodes.
And if the user has finished editing and switch to other nodes, everything went back to normal. I have tried setting the labels to empty strings when the user clicks on the editing control but that only hides the main label (the one in the center), but the labels on the nodes are still there.
$('.olControlModifyFeatureItemInactive').click(function() {
polygonLayer.styleMap.styles.default.defaultStyle.label = "";
polygonLayer.redraw();
});
What is happening there and how do I prevent duplicated area values from showing up?
Take a look at THIS
You should be able to setup context on our style map and only return the label if it's NOT in edit mode:
var styleMap = new OpenLayers.StyleMap(new OpenLayers.Style({
label: "${getLabel}"
// your other symbolizer properties here
}, {context: {
getLabel: function(feature) {
if(!mycontrolIsNotInEditMode) {
return feature.attributes.label;
}
}
}}
));
Related
I have a Kendo UI treeview which contains some node that i load children on expand by firing a ajax call and returning a data array. This works fine and i get the data and it binds to the tree.
However the issue occurs after the first expand of a node, when i expand the node first time the tree behaves correctly and everything is fine, however if i collapse and expand the node again the tree does not push the other nodes down and the expanded node overlaps all other icons in tree.
Expanded on first run
Second Expand
This happens for all the nodes that i expand on the 2nd run.
Here is the code that i use to build the tree
$('#all-library-tree').kendoTreeView({
loadOnDemand: true,
dataSource: _masterTreeViewMasterObj.sort().reverse(), // top level nodes
dataTextField: "text",
expand: function (e) {
var treeView = $('#all-library-tree').data('kendoTreeView');
var dataItem = treeView.dataItem(e.node);
dataItem.load();
if (dataItem.children.data().length !== 0) return;
if (dataItem.id === -1) {
//get unused data children for node
GetUnUsedChildrenForRHSTree(dataItem.text, dataItem.children);
}
}
});
So i was able to fix this issue by adding dataItem.loaded("false"); just before dataItem.load(); hope this helps someone in the future.
I have a grid I created in Gridx which lists a bunch of users. Upon clicking a ROW in the grid (any part of that row), a dialog pops up and shows additional information about that user and actions that can be done for that user (disable user, ignore user, etc.) - when one of these options is selected from the pop up, I want to DISABLE that row. The logic for getting the row, etc. I can take care of, but I can't figure out how to make a grid row actually "appear" disabled and how to make that row no longer clickable.
Is there a simple way to do this? If you aren't familiar with gridx, solutions that apply to EnhancedGrids or other Dojo grids are also appreciated.
Alright now that I have a little more information here is a solution:
Keep a list of all the rows you have disabled so far either inside the Grid widget or in its parent code. Then on the onRowClick listener I would write code like this:
on(grid, "onRowClick", function(e) {
if(disabledRows[rowIndex]) {
return;
}
// Do whatever pop up stuff you want and after
// a user selects the value, you can "disable"
// your row afterwards by adding it to the disabled
// list so that it can no longer be clicked on.
var rowIndex = e.rowIndex;
disabledRows[rowIndex] = true;
// This is just some random class I made up but
// you can use css to stylize the row however you want
var rowNode = e.rowNode;
domClass.add(rowNode, "disabled");
});
Note that domClass is what I named "dojo/dom-class". Hope this helps!
This is perhaps not exactly what you are seaching for:
If you want to hide one or more rows by your own filterfunction you could just add to these rows in the DOM your own class for nodisplay. Here I show you a function for display only those rows which have in a choiceable field/column a value inside your filterlist.
function hideRowFilter(gridId, fieldName, filterList)
{
var store = gridId.store;
var rowId;
store.query(function(object){
rowId = gridId.row(object.id,true).node();
if (filterList.indexOf(object[fieldName]) == -1)
domClass.add(rowId, "noDisplay"); // anzeigen
else
domClass.remove(rowId, "noDisplay"); // verstecken
});
}
CSS:
.noDisplay { display: none; }
So I can for example display only the entries with a myState of 3 or 4 with this call:
hideRowFilter(gridId, 'myState', [3, 4]);
Note that domClass is what I named "dojo/dom-class"
I am trying to bind the datapoints with the onclick event, so that I could display a overlay box with some additional details and links. I'm using the .nv-point class to access the datapoints. The problem is that I'm unable to register the onclick event to those datapoints.
Here is the code :
d3.selectAll(".nv-point").on("click",function(){
alert("clicked");
//do something more
});
Here is the demo in jsFiddle
You can easily attach a click handler to the "circle", or node point on a lineChart like this:
chart.lines.dispatch.on('elementClick', function(e) {
alert("You've clicked on " + e.series.key + " - " + e.point.x);
});
In the above example, this will show the Key (of the line) and the exact x value of the node you've clicked on. I find it very helpful to set a breakpoint on the alert line, and using Chrome/FF/etc developer tools, inspect the thee object so you can see exactly what data is available and how to access it.
After much futzing around, this seems to work for me:
d3.select("#mainGraph svg").selectAll(".nv-point").style("pointer-events", "all").on("click", function( e ) { console.log( JSON.stringify( e ) ); });
Basically, the difference between what I've done and what you originally tries is just resetting overriding the stylesheet to turn on pointer-events, i.e. style("pointer-events", "all").`
The line plot is made with svg lines, which have class nv-line. A fork of your original jsFiddle is here: http://jsfiddle.net/pnavarrc/qzwkn/1/
d3.selectAll(".nv-line").on("click", function () {
alert("clicked");
});
If you feel like having a look at the source code of nvd3:
https://github.com/novus/nvd3/blob/master/src/models/lineChart.js
https://github.com/novus/nvd3/blob/master/src/models/line.js
You could just add the argument, that will link it to the data point.
In my case, I was trying to hyperlink for each data point.
The arguments has value passed, which can be used to update hyperlink as per requirement.
d3.selectAll(".nv-point").on("click", function (e) {
alert(e[0].values[0]);
});
I am trying to print a multiple-page FlexPrintJob, that includes on the first page, several labels, then a PrintDataGrid. It all prints, except that the PrintDataGrid only prints using half the page on all the pages.
I know it has to do with the labels that I am printing on page 1, because taking them off or hiding them fixes the issue and the grid prints full page all pages.
I have tried various containers around the grid and labels, including VBox, VGroup, Group, and specifying different combinations of height="100%" for some of the containers.
Is it simply not possible to print a half page of variables / labels on page 1, then start the data grid on the same page (half page worth), but then have it go to full page on the following pages?
Here is my print job code:
var printJob:FlexPrintJob = new FlexPrintJob();
if (printJob.start()) {
var thePrintView:printViewEventUser = new printViewEventUser(); // Create a FormPrintView control as a child of the application.
addElement(thePrintView);
thePrintView.width=printJob.pageWidth;
thePrintView.height=printJob.pageHeight;
thePrintView.parentEncounter=parentEncounter; //pass in my object for the labels to print
thePrintView._currentRec=_currentRec; //pass in my object for the labels to print
thePrintView.myDataGrid.dataProvider = bedSearchEditList._recs;
thePrintView.showPage("single"); // Create a single-page image.
if(!thePrintView.myDataGrid.validNextPage) // If the print image's DataGrid can hold all the data provider's rows, add the page to the print job.
{
printJob.addObject(thePrintView,FlexPrintJobScaleType.NONE);
}
else // Otherwise, the job requires multiple pages.
{
thePrintView.showPage("first"); // Create the first page and add it to the print job.
printJob.addObject(thePrintView);
thePrintView.pageNumber++;
while(true) //queue pages
{
thePrintView.myDataGrid.nextPage(); // Move the next page of data to the top of the PrintDataGrid.
thePrintView.showPage("last"); // Try creating a last page.
if(!thePrintView.myDataGrid.validNextPage) // If the page holds the remaining data, or if the last page was completely filled by the last grid data, queue it for printing. Test if there is data for another PrintDataGrid page.
{
printJob.addObject(thePrintView,FlexPrintJobScaleType.MATCH_WIDTH); // This is the last page; queue it and exit the print loop.
break;
}
else // This is not the last page. Queue a middle page.
{
thePrintView.showPage("middle");
printJob.addObject(thePrintView,FlexPrintJobScaleType.MATCH_WIDTH);
thePrintView.pageNumber++;
}
}
}
removeElement(thePrintView);
}
printJob.send(); // Send the job to the printer.
My print view object is basically just an around my labels, then a PrintDataGrid.
If I remember correctly I fixed a similar situation in the past specifying a minHeight property to my mx:PrintDataGrid like this..
<mx:PrintDataGrid id="printViewDataGrid" width="100%" minHeight="500">
...
</mx:PrintDataGrid>
Good luck!
I'm trying to enable a double click event on a flex control without disabling the default mouseup/mousedown behaviors.
I'm using the ESRI Flex API for arcgis server, and I have a map control with one background layer and a GraphicLayer. The graphics layer has several Graphic objects that respond to mouseover, and allow the user to pan the map if they click and hold. However, when I implement a double click event handler for the graphic objects, they no longer seem to bubble up their default behavior to the map.
Is there a way to implement a double click on a Graphic object while preserving the old behavior from clicking and holding?
I solved this by attaching the double click event to the map, rather than the graphic, and using the target attribute of the event to get the graphic I wanted to use.
Like this:
map.addEventListener(MouseEvent.DOUBLE_CLICK, function(event:MouseEvent):void
{
var graphic:Graphic = event.target as Graphic;
if(graphic)
{
...
}
});
If you set the "checkForMouseListeners" property to false on your Graphic objects, then the default map click/drag behavior will be preserved.
graphic.addEventListener(MouseEvent.DOUBLE_CLICK, function(event:MouseEvent):void {
var graphic:Graphic = event.target as Graphic;
if(graphic) {
...
}
});
//preserve the default click/drag behavior on the map
graphic.checkForMouseListeners = false;
http://resources.esri.com/help/9.3/ArcGISServer/apis/Flex/apiref/com/esri/ags/Graphic.html#checkForMouseListeners