1. dynamically fill dijit. Form. multiselect
Multiselect does not support dojo. Data (that is, datastore), so if you want to dynamically fill in a datastore, you can only write some JavascriptCodeTo dynamically create those <option> labels, basically through mydatastore. Fetch. This link (populating markup multiselect) is worth your reference.
2. Force a datastore to retrieve data from the URL
Mydatastore. _ forceload ();
3. When datastore contains a nested structure, datastore. Fetch () reports the error "dojo _ 48 is undefined"
The reason is that the resulting JSON string contains the "identifier" declaration, but some objects in the nested structure do not contain the declared attributes. Solution 1: Let all objects contain this attribute; 2. Remove the "identifier" Declaration (recommendation 1, because I guess after removing this declaration, in some controls, ID values cannot be mapped to HTML code.) Reference link 1 Reference link 2
4. Respond to events in Dojo
See JavaScript events and dojo
5. Refresh bordercontainer
Sometimes you need to dynamically hide some areas (such as left) in bordercontainer. if the display is set to "NONE", the part of the area will become blank, and other areas (such as the center) will not automatically occupy its original screen space. In this case, you need to call the dojo. byid ('myborderiner iner '). layout () method to manually re-calculate the layout. Other layout s are similar. A related link (only for the old version of dojo)
6. Use dojo to draw statistical charts (bar charts, pie charts, etc)
See this tutorial: a beginner's Guide to dojo charting (Part1, Part2)
7,ProgramChange the title of dijit. Dialog
Dijit. Dialog does not provide a "settitle" method to control the title content, but it can be implemented through dijit. byid ('mydid'). titlenode. innerhtml = 'My new title. Reference
8. Display and hide pane in bordercontainer
Using dojox. layout. expandopane (not sure whether it is experimental yet), see this link for examples.
9. serialize itemfilewritestore into a JSON string
VaR Foo = dojo. Data. itemfilewritestore. _ getnewfilecontentstring ();
10. handleas can have the following values in xhr (XMLHttpRequest) of dojo:
Text (default), JSON, JSON-comment-optional, JSON-comment-filtered, JavaScript, XML
Reference
11. Send data in datastore to the server in xhr mode and process the returned values.
Write in JS as follows:
VaR DATA =Scenarioentrystore. _ getnewfilecontentstring (); dojo. rawxhrpost ({URL:"Http: // 127.0.0.1: 8080/MyApp/myservlet", Handleas:"Text", Postdata: data, headers :{"Content-Type": "application/JSON"}, Handle: function (data, argS ){If(Typeof (data) = "error") {Alert ("Error run analysis");}Else{Alert ("Successed run analysis");//Do with result data}}});
In myservlet, use the following method to obtain the JSON string passed by JS, and then use any Java JSON package for parsing and processing:
private string readjsonstring (httpservletrequest request) {stringbuffer JSON = New stringbuffer (); string line = null ; try { bufferedreader reader = request. getreader (); while (line = reader. readline ())! = null ) {JSON. append (line) ;}} catch (exception e) {system. out. println (E. tostring () ;} return JSON. tostring () ;}
12. When xhr is used, if it is not accessed on the local machine, you may encounter a prompt "access to restricted URI denied.
One possible reason is that the domain of the URL in xhr is inconsistent with the domain of the visitor's browser (or anything else, which is not clear here). If this is the reason, you only need to use the relative path in the URL. For example, if the original URL is "http: // 127.0.0.1: 8080/MyApp/myservlet", change it to "myservlet. For this reason, refer to this link.
13. The Click Event in Dojo is "onclick", which is not recognized as "onclick. (However, onchange is all lowercase, which is strange enough)
14. Draw data in JSON format to the dojo chart
The following is an example of converting JSON data to an array. From this link, prototype is actually used.
//JSON:STR = "{values: [1, 2, 3, 4, 5]} ";//Using prototypeOBJ =Str. evaljson ();//The array is then referenced:Chart1.addseries ("Series 1", obj. values );
The following method uses the JSON format (from here), but I have not found a complete introduction to the use of the valuefn parameter:
< Div Dojotype = "Dojox. charting. widget. chart2d" ID = "Chart4" Theme = "Dojox. charting. Themes. plotkit. Green" Style = "Width: 300px; Height: 300px ;" > < Div Class = "Plot" Name = "Default" Type = "Pie" Radius = "100" Fontcolor = "Black" Labeloffset = "-20" > </ Div > < Div Class = "Series" Name = "Series C" Store = "Tablestore" Valuefn = "Number (x )" > </ Div > < Div Class = "Action" Type = "Tooltip" > </ Div > < Div Class = "Action" Type = "Moveslice" Shift = "2" > </ Div > </ Div >
15. scalable pane
Use expandopane (// test link Todo. It should be noted that expandopane has a bug in versions earlier than dojo 1.3, which means that when the drawer pane is included, the lower drawer in IE will be squeezed out, and it will be normal in Firefox. Dojo 1.3 solves this problem.
(Unless otherwise stated, the above are applicable to the dojo 1.3 version. )
(The following is the dojo 1.6 version. dojo is always crazy and you have to remember some difficult experiences)
16. The legend (LEGEND) of the dojo chart must be created after chart. Refresh () or refresh (). Otherwise, the color and shape are not correctly displayed in the legend, but they are all "X ". (Reference)
17. For charts drawn in tabcontainer, the tab page of refresh () is hidden. After switching, the chart size cannot be filled with the tabcontainer area.
I still don't know what the correct method is. An exercise is to call the chart resize () method when the tab is switched to the tab where the chart is located. For example:
Dojo. subscribe ("mytabcontainer-selectchild", Function (child ){If(Child. ID = "mytab") MyChart. Resize ();});