/>
<span id="${field_id}_info" />
</span>
+'''
+
+AlumnoMultiSelectAjax = '''
+
+ function _on_alumno_get_result(lista, results)
+ {
+ load.style.visibility = 'hidden';
+ if (results.error) {
+ alert(results.msg);
+ return;
+ }
+ MochiKit.DOM.appendChildNodes(lista, OPTION(results.msg));
+ }
+
+ function _on_alumno_get_error(results)
+ {
+ alert(results)
+ load.style.visibility = 'hidden';
+ }
+
+ function agregar_a_la_lista(texto, lista)
+ {
+ load = MochiKit.DOM.getElement('loading');
+ load.style.visibility = 'visible';
+ t = MochiKit.DOM.getElement(texto);
+ url = "/grupo/get_inscripto?cursoid=1&padron="+t.value;
+ var d = loadJSONDoc(url);
+ d.addCallbacks(partial(_on_alumno_get_result, lista), _on_alumno_get_error);
+ t.value = "";
+ }
+
+ function sacar_de_la_lista(lista)
+ {
+ l = MochiKit.DOM.getElement(lista);
+ if (l.selectedIndex < 0) return;
+
+ /* caso especial, 1 solo item */
+ if (l.options.length == 1) {
+ l.options.length = 0
+ return;
+ }
+
+ for (i=l.selectedIndex; i<l.options.length-1;i++)
+ l.options[i] = l.options[i+1];
+ }
+'''
+
+class AlumnoMultiSelect(widgets.MultipleSelectField):
+ template = '''
+ <table xmlns:py="http://purl.org/kid/ns#" style="border:none; width:0%;">
+ <tr><td>
+ <input type="text" id="${field_id}_nuevo" />
+ <img src="/static/images/loading.gif" align="baseline" style="visibility:hidden;" id="loading" width="16px" height="16px" />
+ <input type="button" id="_agregar" value="Agregar"
+ onClick=" agregar_a_la_lista('${field_id}_nuevo', '${field_id}'); " />
+ </td></tr>
+ <tr><td>
+ <select
+ multiple="multiple"
+ size="${size}"
+ name="${name}"
+ class="${field_class}"
+ id="${field_id}"
+ py:attrs="attrs"
+ style="width:250px;"
+ >
+ <optgroup py:for="group, options in grouped_options"
+ label="${group}"
+ py:strip="not group"
+ >
+ <option py:for="value, desc, attrs in options"
+ value="${value}"
+ py:attrs="attrs"
+ py:content="desc"
+ />
+ </optgroup>
+ </select>
+ </td></tr>
+ <tr><td align="center">
+ <input type="button" id="_sacar" value="Borrar"
+ onClick="sacar_de_la_lista('${field_id}'); " />
+ </td></tr>
+ </table>
'''
+ javascript = [widgets.JSSource(AlumnoMultiSelectAjax)]
+