Wtx ~ Wt Extension Library
WtxLib
Classes | Public Member Functions | Public Attributes | List of all members
Wtx::Dbo::FieldDefLookupBase Class Reference

Single-line Editor. More...

#include <FieldDefLookupBase.h>

+ Inheritance diagram for Wtx::Dbo::FieldDefLookupBase:

Classes

class  Provider
 

Public Member Functions

 FieldDefLookupBase (TableDef &td, const char *fn, int w=-1, int h=-1, Flags f=Flags::None, std::string lb="", std::string ph="", std::string inf="", std::string tt="", int ht=-1)
 ctor More...
 
 FieldDefLookupBase (TableDef &td, const char *fn, std::string lb="", std::string ph="", std::string inf="", std::string tt="", int ht=-1)
 
Providerprovider ()
 
- Public Member Functions inherited from Wtx::Dbo::FieldDefBase
 FieldDefBase (TableDef &td, const char *fn, int w=-1, int h=-1, Flags f=Flags::None, std::string lb="", std::string ph="", std::string inf="", std::string tt="", int ht=-1)
 ctor field definition object More...
 
 FieldDefBase (TableDef &td, const char *fn, std::string lb="", std::string ph="", std::string inf="", std::string tt="", int ht=-1)
 ctor field definition object More...
 
virtual Wtx::Dbo::TableDeftableDef () const
 
virtual const char * fieldName () const
 
virtual const std::string & aliasName () const
 
virtual int width () const
 
virtual void setWidth (int value)
 
virtual int height () const
 
virtual void setHeight (int value)
 
virtual bool isVisible () const
 
virtual void setIsVisible (bool value=true)
 
virtual bool isReadOnly () const
 
virtual void setIsReadOnly (bool value=true)
 
virtual bool isUnique () const
 
virtual void setIsUnique (bool value=true)
 
virtual const std::string & label () const
 
virtual void setLabel (const std::string &value)
 
virtual const std::string & placeholderText () const
 
virtual void setPlaceholderText (const std::string &value)
 
virtual const std::string & info () const
 
virtual void setInfo (const std::string &value)
 
virtual const std::string & toolTip () const
 
virtual void setToolTip (const std::string &value)
 
virtual int helpTopic () const
 
virtual void setHelpTopic (int value)
 
virtual const Flagsflags () const
 
virtual void setFlags (const Flags value)
 
virtual const std::string & defaultValue () const
 
virtual void setDefaultValue (const std::string &value)
 
virtual bool forceUppercase () const
 
virtual void setForceUppercase (bool value=true)
 
virtual const std::string & inputMask () const
 
virtual void setInputMask (const std::string &mask="", Wt::WFlags< Wt::InputMaskFlag > flags=Wt::None)
 
virtual std::unique_ptr< Wt::WItemDelegate > createItemDelegate (int sid, Wtx::Dbo::Session &session) const
 
virtual std::unique_ptr< Wt::WWidget > createLabelWidget (int sid, Wtx::Dbo::Session &session) const
 
virtual std::unique_ptr< Wt::WWidget > createEditWidget (int sid, Wtx::Dbo::Session &session) const
 
virtual std::unique_ptr< Wt::WWidget > createDisplayWidget (int sid, Wtx::Dbo::Session &session) const
 
virtual std::string toJson () const
 
virtual void fromJson (const std::string &valud)
 

Public Attributes

std::shared_ptr< Wt::WAbstractItemModel >(* getLookupModel )(int sid, int tid, const std::string &filter, Wtx::Dbo::Session &session) = nullptr
 create a look-up model More...
 
std::unique_ptr< Wt::WTableView >(* getTableView )(int sid, int tid, const std::string &filter, Wtx::Dbo::Session &session) = nullptr
 
std::unique_ptr< Providerm_provider
 

Additional Inherited Members

- Public Types inherited from Wtx::Dbo::FieldDefBase
enum  Flags {
  None = 0x0000, Required = 0x0001, ReadOnly = 0x0002, Password = 0x0004,
  ShowOnly = 0x0008, NoUi = 0x0010, Unique = 0x0020, Search = 0x0040
}
 Field Definition Flags. More...
 

Detailed Description

Single-line Editor.

Definition at line 60 of file FieldDefLookupBase.h.

Constructor & Destructor Documentation

Wtx::Dbo::FieldDefLookupBase::FieldDefLookupBase ( TableDef td,
const char *  fn,
int  w = -1,
int  h = -1,
Flags  f = Flags::None,
std::string  lb = "",
std::string  ph = "",
std::string  inf = "",
std::string  tt = "",
int  ht = -1 
)

ctor

Parameters
fnowning table definition (ro required)
wfield name (ro required)
hwidth
fheight
lbflags
phlabel
infplaceholder text
ttinfo
httooltipText help topic

Definition at line 55 of file FieldDefLookupBase.cpp.

Wtx::Dbo::FieldDefLookupBase::FieldDefLookupBase ( TableDef td,
const char *  fn,
std::string  lb = "",
std::string  ph = "",
std::string  inf = "",
std::string  tt = "",
int  ht = -1 
)
Parameters
fnowning table definition (ro required)
lbfield name (ro required)
phlabel
infplaceholder text
ttinfo
httooltipText help topic

Definition at line 72 of file FieldDefLookupBase.cpp.

Member Data Documentation

std::shared_ptr<Wt::WAbstractItemModel>(* Wtx::Dbo::FieldDefLookupBase::getLookupModel) (int sid, int tid, const std::string &filter, Wtx::Dbo::Session &session) = nullptr

create a look-up model

some of the widgets can employ a lookup-model. This is used to fill in some of the field values, for combo-boxes and suggestion-boxes and so on.

the lookup-model is a model based on some other table connection. the resulting model values can depend on a source-id (sid) and a target-id (tid).

for instance, a model can be a simple combo-box look-up value, such as, "all items from look-up table that contain 'container' as a group". Another model could contain all "products for customer X". In this case, it is necessary to generate a model as a list of things connected to something else. in this case the customer is sent as the 'sid' value, and the creator will generate a model that contains all products for customer 'sid'.,

the target-id (tid) value is used when only that one item should be returned in the model. This is used in cases where a form is being pre-loaded, and it is not necessary to load every item for the model. This will be an attempt at lazy loading. When the edit field receives focus, then the call to create the model will be re-engaged so that all the items out of the model can be acquired.

The .sid. and .tid. values are not necessarily required by the model creator, but they are provided in case they are needed.

Parameters
sidsource-id
tidtarget-id
sessionsession controller
60 //
61 // this function creates a model for looking
62 // up a company. it does not use the .sid. or .tid. values.
63 //
68 std::shared_ptr<Wt::WAbstractItemModel> getCompanyModel( int sid, int tid, Wtx::Dbo::Session & session )
69 {
70 auto retVal = std::make_shared< Wtx::Dbo::QueryModel< std::tuple<int,std::string> > >();
71
72 Wt::Dbo::Transaction t(session);
73
80 auto query =
81 session.query< std::tuple<int,std::string> >( "SELECT id,\"keyField\" || ' ~ ' || \"cfyField\" AS key FROM \"crmCompany\"" )
82 .where("id in (select distinct \"forOwner_crmCompany_id\" from \"mrpProduct\")")
83 ;
85
86 retVal-> setQuery( query );
87 retVal-> addColumn("id");
88 retVal-> addColumn("key");
89
90 return retVal;
91 }
92
95 Mrp::Product::Definition::Definition()
96 : Wtx::Dbo::PermissionTableDef("mrpProduct"),
97 ProductNumberFieldDef( *this, "productNumber" ),
111 TaxAuthFieldDef( *this, "taxAuth" ),
131 NoteFieldDef( *this, "note" ),
132 WarnFieldDef( *this, "warn" ),
134 Cost1FieldDef( *this, "cost1" ),
135 Cost10FieldDef( *this, "cost10" ),
136 Cost100FieldDef( *this, "cost100" ),
147 LotTrackingFieldDef( *this, "lotTracking" ),
148 LotNumberFieldDef( *this, "lotNumber" ),
150 ForOwnerFieldDef( *this, "forOwner_crmCompany" ),
151 {
192 ForOwnerFieldDef.setLabel("Owner");
193 ForOwnerFieldDef.getLookupModel = &getCompanyModel;
194 ForOwnerFieldDef.setIsReadOnly();

Definition at line 198 of file FieldDefLookupBase.h.


The documentation for this class was generated from the following files: