TODO: Tutorial and more docs.
To use these filters, add the following to your Django template:
{% load extjs %}
Note that the examples below assume that devilry.examiner.restful.RestfulSimplifiedDelivery is available as a template variable as RestfulSimplifiedDelivery. You may use any RESTful class in place of RestfulSimplifiedDelivery.
Simple usage:
// Create a variable with the extjsmodel class definition
var deliverymodel = {{ RestfulSimplifiedDelivery|extjs_model }};
// Often you will rather define a model and use it later with the
// extjs_modelname filter (or a combination of both approaches)
{{ RestfulSimplifiedDelivery|extjs_model }};
var deliverymodelname = {{ RestfulSimplifiedDelivery|extjs_modelname }};
var model = Ext.ModelManager.getModel(deliverymodelname);
Specifying result_fieldgroups and model name suffix:
// Specify result_fieldgroups
{{ RestfulSimplifiedDelivery|extjs_model:"assignment_group,deadline" }};
// ... or specify a name suffix (to make the model name unique)
// Notice the ;
{{ RestfulSimplifiedDelivery|extjs_model:";MyScope" }};
// ... or specify result_fieldgroups and suffix
{{ RestfulSimplifiedDelivery|extjs_model:"assignment_group,deadline;MyScope" }};
// Note that you can use extjs_modelname to get a suffixed name
{{ RestfulSimplifiedDelivery|extjs_modelname:"MyScope" }};
Create an extjs model from the given restful class. Uses restfulcls_to_extjsmodel().
Parameters: |
|
---|
var modelname = {{ RestfulSimplifiedDelivery|extjs_modelname }};
Get the name of the extjs model generated by extjs_model() using the same restfulcls.
Uses get_extjs_modelname().
var comboboxmodel = {{ RestfulSimplifiedDelivery|extjs_combobox_model }};
Wrapper for restfulcls_to_extjscomboboxmodel().
var deliverystore = {{ RestfulSimplifiedDelivery|extjs_store }};
Create an extjs store from the given restful class. Uses restfulcls_to_extjsstore().
Parameters: | storeidsuffix – Forwarded directly to restfulcls_to_extjsstore(). |
---|
Get the ExtJS model name for the given restful class. Generated from the module name and class name of restfulcls._meta.simplified
Parameters: | modelnamesuffix – Suffixed to the generated model name. |
---|
Create an extjs model from the given restful class.
Parameters: |
|
---|
Create an extjs model from the given restful class.
Parameters: |
|
---|
Shortcut for:
restfulcls_to_extjsmodel(restfulcls,
restfulcls._extjsmodelmeta.combobox_fieldgroups,
modelnamesuffix)
Get the ExtJS store id for the given restful class. Generated from the store id and class name of restfulcls._meta.simplified
Parameters: | storeidsuffix – This string added to the end of the id. |
---|
Create an extjs store from the given restful class.
Parameters: |
|
---|
See Low level RESTful web service API.
Decorator for RESTful classes.
Checks for, and adds defaults for the extjs specific inner meta class, ExtjsModelMeta.
ExtjsModelMeta can have the following attributes:
- combobox_displayfield
- When this object is used in a combobox (search, foreign-key, ...), the combobox need a field, displayField, to show after the an item has been selected (when not showing a dropdown). This attribute species a field name in the resultdata from devilry.simplified.SimplifiedModelApi.search() to use as displayField for comboboxes. Defaults to 'id'.
- combobox_fieldgroups
- Species the result_fieldgroups to send to devilry.simplified.SimplifiedModelApi.search() when querying for data in a combobox (see combobox_displayfield for more details on comboboxes). Defaults to an empty list.
- combobox_tpl
- Species the Ext.XTemplate (an extjs class) template to use for each item in the combobox dropdown (see combobox_displayfield parameter for more details on comboboxes). Defaults to '{combobox_displayfield}'.