MxGraph - Javascript function for ID value for the cell - mxgraph

When we drop and drag the object into diagram canvas, the id attribute is assigned to that object. The id values are unique one. Which Javascript function in mxgraph called for the assign id value for the cell?

mxGraphModel.prototype.createId

Related

Unique signature for a DOM element in absense of ID?

DOM Elements are identified by their "id" value when it is present. But in absence of it can we write a function that generates an "id" ? If called multiple times the function need to return the same ID for the same DOMElement.
Every element has its css selector that points to it uniquely, you can add id for example by jquery:
$(*unique selector*).attr('id', 'element_id');
and afterwards to reference this element by this id.
You can also call this element by its css selector everytime - if it's unique enough, it can act like an id, but it introduces additional overhead.
For example, your question's selector is:
var el = $('#question table td.postcell div.post-text p');
You can set it's id:
el.attr('id','your_question');
Now you can reference it by this new id:
alert($('#your_question').text());
try it in your Firebug console.

Add HTML 5 data attribute to a newly created row when table is using datatable js

I have a HTML table with each row with HTML5 data attribute. The table is using jQuery Datatables plug-in. Now when I am adding a new row on a click of button how to add HTML5 data attribute to it again. The data attribute value is specified by the user.
Data attribute write:
$('#categories-table').dataTable
'createdRow': (row, data, dataIndex) ->
$(row).attr('data-category-id', data[0])
Data attribute read:
$('#categories-table tbody').on 'click','tr', () ->
console.log $(this).data('category-id')
You may want to look at http://datatables.net/reference/option/columns.createdCell
that's a callback for once the cell is created so you can modify it and add your custom attributes or for the row http://datatables.net/reference/option/createdRow
(using the current v1.10.4)

AS3 Load library movie based on parameter on Parent

I have following scenario:
I have created a movie symbol at library called mov_Child. Which has dynamic text field. But I have to pass parent movies text value to the mov_Child's dynamic text field.
How can I do that?
Give instance name to dynamic textfield e.g. "myTextField"
var parentMoviesText:String = "This is parent movies text";
mov_Child.myTextField.text = parentMoviesText; // Here you pass the text value

primefaces update table row after cell edit

I am using primefaces datatbale cell editing , when I edit the a cell the next column of that row should display a calculated value which is calculated from this cell value,I am using celleditEvent to invoke a listener using
Please advice in my listener is there a way to retrieve the id of the tr and add to request context to update this row. Please advice.
public void onCellEdit(CellEditEvent cellEditEvent){
RequestContext.getCurrentInstance().update(((DataTable)cellEditEvent.getSource()).getClientId());
}
in this event method it it possible to retrieve html id of the tr element containing this cell.
Try to use OmniFaces with PrimeFaces
Take a look at this : http://showcase.omnifaces.org/utils/Ajax

D3.js: How to combine 2 datasets in order to create a map and show values on.mouseover?

I would like to combine two datasets on a map in D3.js.
For example:
1st dataset: spatial data in .json.
2nd dataset: Data to the areas in .csv
--> When you hover on the map a tooltip should show a sentences with some data from the 2nd dataset.
I am able to make the map and show a tooltip with data within the .json-file, but how do I insert the 2nd dataset?
A new function within my function that creates the map?
Do I have to take a completely new way?
Should I merge the .json-file with my 2nd dataset before using d3.js?
I appreciate any thoughts! :)
So, I think what you're asking is how to take spatial data from json and join it with some csv data that is loaded separately?
I did something similar with a choropleth map I was drawing and basically I just created a map of topology element ids to data objects and then I did a lookup using the topology element id to get whatever I wanted to associate with the actual drawn map element (I was using this method to set the color for the choropleth based on the fips country code).
So basically, draw the map so that you have an id associated with each map element that you want to be able to hover over. Then, in your mouseover/mouseout handlers, you will use that id to lookup the data you want to show in the tooltip and either use the svg title element or tipsy or manually draw an svg text element or whatever to show the tooltip.
Here's a couple useful references for drawing tooltips:
https://gist.github.com/biovisualize/1016860
http://jsfiddle.net/reblace/6FkBd/2/
From the fiddle:
function mouseover(d) {
d3.select(this).append("text")
.attr("class", "hover")
.attr('transform', function(d){
return 'translate(5, -10)';
})
.text(d.name + ": " + d.id);
}
// Toggle children on click.
function mouseout(d) {
d3.select(this).select("text.hover").remove();
}
Basically, it's appending an SVG text element and offsetting it from the position of the element being hovered over.
And here's a sample of how I look up data in an external map:
// Update the bound data
data.svg.selectAll("g.map path").transition().duration(750)
.style("fill", function(d) {
// Get the feature data from the mapData using the feature code
var val = mapData[d.properties.code];
// Return the colorScale value for the state's value
return (val !== undefined)? data.settings.colorScale(val) : undefined;
});
If your data is static, you can join it into your topojson file (if that's what you're using). https://github.com/mbostock/topojson/wiki/Command-Line-Reference
The client could change my data, so I kept it separate and redrew the map each time the data changed so that the colors would update. Since my data was topojson, I could access the feature id from the map data using d.properties.code (because I had joined the codes into the topojson file using the topojson tool I reference above... but you could use whatever unique id is in the spatial data file you have).