doc:appunti:linux:lezioni:pmapper_dev
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
doc:appunti:linux:lezioni:pmapper_dev [2010/04/28 19:43] – niccolo | doc:appunti:linux:lezioni:pmapper_dev [2011/07/21 09:33] – [Dialog box con PM.Dlg.createDnRDlg] niccolo | ||
---|---|---|---|
Line 38: | Line 38: | ||
Purtroppo il plugin UI non è nella sua versione completa, mancano ad esempio i widget // | Purtroppo il plugin UI non è nella sua versione completa, mancano ad esempio i widget // | ||
- | * **'' | + | * **'' |
- | * **'' | + | * **'' |
- | I due file devono essere richiamati dal file **'' | + | Per caricare un file **.js** o un file **.css** basta copiarlo nella directory **'' |
+ | |||
+ | Se si vuol un controllo maggiore sull' | ||
<code html> | <code html> | ||
- | <script type=" | + | <script type=" |
- | <link rel=" | + | <link rel=" |
</ | </ | ||
+ | |||
La **'' | La **'' | ||
Line 114: | Line 117: | ||
}); | }); | ||
</ | </ | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===== Formattazione numeri risultato query ===== | ||
+ | |||
+ | Il risultato di una query tramite lo strumento **Seleziona** viene mostrato in un dialog box, purtroppo i numeri vengono formattati come numeri con cinque decimali, anche se si tratta di numeri interi. | ||
+ | |||
+ | Per migliorare l' | ||
+ | |||
+ | <code javascript> | ||
+ | if (!(noShpLink && i == 0)) | ||
+ | h.append(layTpl.tvalues['# | ||
+ | | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | con | ||
+ | |||
+ | <code javascript> | ||
+ | if (!(noShpLink && i == 0)) { | ||
+ | var value; | ||
+ | if (String(this).match(/ | ||
+ | value = parseFloat(this).toFixed(0); | ||
+ | } else if (String(this).match(/ | ||
+ | value = parseFloat(this).toFixed(3); | ||
+ | } else { | ||
+ | value = this; | ||
+ | } | ||
+ | h.append(layTpl.tvalues['# | ||
+ | | ||
+ | ); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | I **numeri interi** sono formattati senza decimali, i **float con solo 3 decimali** e tutto il resto rimane invariato. | ||
+ | |||
+ | ===== Dialog box con PM.Dlg.createDnRDlg ===== | ||
+ | |||
+ | Thanks to Armin Burger for the following details. | ||
+ | |||
+ | In plugins writing or extending p.mapper code, it is nice to use dialog boxes in the p.mapper way. Here it is an example for the **'' | ||
+ | |||
+ | <code javascript> | ||
+ | var dlgOptions = { | ||
+ | width: 640, height: 480, left: 100, top: 50, | ||
+ | resizeable: true, | ||
+ | newsize: true, | ||
+ | container: ' | ||
+ | name: ' | ||
+ | }; | ||
+ | |||
+ | var dlg = PM.Dlg.createDnRDlg( | ||
+ | dlgOptions, | ||
+ | ' | ||
+ | popupUrl | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | The non-trivial options are: | ||
+ | |||
+ | ^ '' | ||
+ | ^ '' | ||
+ | ^ '' | ||
+ | |||
+ | Once the dialog is opened, it can be addressed (e.g. to change its content) using jQuery. In the following example if the dialog does not exists, it will be created; otherwise its content is reloaded and it is shown: | ||
+ | |||
+ | <code JavaScript> | ||
+ | var dlgOptions = { | ||
+ | width: 640, height: 480, left: 100, top: 50, | ||
+ | resizeable: true, newsize: true, | ||
+ | container: ' | ||
+ | name: ' | ||
+ | }; | ||
+ | |||
+ | var popupUrl = PM_PLUGIN_LOCATION + '/ | ||
+ | var dlgObject = $('#' | ||
+ | if (dlgObject.length < 1) { | ||
+ | var dlg = PM.Dlg.createDnRDlg(dlgOptions, | ||
+ | } else { | ||
+ | $.ajax({ | ||
+ | url: popupUrl, | ||
+ | type: ' | ||
+ | dataType: ' | ||
+ | success: function(response) { | ||
+ | dlgObject.html(response); | ||
+ | dlgObject.parent().parent().show(); | ||
+ | } | ||
+ | }); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | When using forms, p.mapper has two handy PM.Form JavaScript functions to read all the form values and to transform them into a string to be used in AJAX post or get requests: | ||
+ | |||
+ | ^ '' | ||
+ | ^ '' | ||
+ |
doc/appunti/linux/lezioni/pmapper_dev.txt · Last modified: 2011/07/21 09:44 by niccolo