added new events to combobox, rendering fixes IE

This commit is contained in:
Peter Schojer
2008-09-03 12:49:54 +00:00
parent b74e41b626
commit 52ab7d01ca
8 changed files with 52 additions and 17 deletions

View File

@@ -60,6 +60,7 @@ class ExtJS_API ComboBoxCellRenderer: public Poco::WebWidgets::Renderer
{
public:
static const std::string EV_SELECTED;
static const std::string EV_AFTERLOAD;
ComboBoxCellRenderer();
/// Creates the ComboBoxCellRenderer.
@@ -72,7 +73,7 @@ public:
void renderBody(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr);
/// Emits code for the page body to the given output stream.
private:
static void onLoad(void* pSender, Poco::Net::HTTPServerResponse* &pResponse);
@@ -81,6 +82,9 @@ private:
static Poco::WebWidgets::JSDelegate createSelectedServerCallback(const ComboBox* pCombo);
/// Adds a server callback for the selected event. The method signature for select is
/// select : ( Ext.form.ComboBox combo, Ext.data.Record record, Number index )
static Poco::WebWidgets::JSDelegate createAfterLoadServerCallback(const ComboBox* pCombo);
/// Create a server callback for afterLoad of ComboBox list
};

View File

@@ -53,6 +53,7 @@ namespace ExtJS {
const std::string ComboBoxCellRenderer::EV_SELECTED("select");
const std::string ComboBoxCellRenderer::EV_AFTERLOAD("load");
ComboBoxCellRenderer::ComboBoxCellRenderer()
@@ -76,6 +77,16 @@ JSDelegate ComboBoxCellRenderer::createSelectedServerCallback(const ComboBox* pC
}
Poco::WebWidgets::JSDelegate ComboBoxCellRenderer::createAfterLoadServerCallback(const ComboBox* pCombo)
{
poco_check_ptr (pCombo);
static const std::string signature("function(aStore, recs, op)");
std::map<std::string, std::string> addParams;
addParams.insert(std::make_pair(RequestHandler::KEY_EVID, ComboBoxCell::EV_AFTERLOAD));
return Utility::createServerCallback(signature, addParams, pCombo->id(), pCombo->afterLoad.getOnSuccess(), pCombo->afterLoad.getOnFailure());
}
void ComboBoxCellRenderer::renderHead(const Renderable* pRenderable, const RenderContext& context, std::ostream& ostr)
{
poco_assert_dbg (pRenderable != 0);
@@ -95,25 +106,31 @@ void ComboBoxCellRenderer::renderHead(const Renderable* pRenderable, const Rende
std::string url(Utility::createURI(addParams, pOwner->id()));
ostr << url << "}),";
ostr << "reader:new Ext.data.ArrayReader()})";
ostr << "reader:new Ext.data.ArrayReader()";
if (pComboOwner && pComboOwner->afterLoad.hasJavaScriptCode())
{
ostr << ",listeners:{";
Utility::writeJSEvent(ostr, EV_AFTERLOAD, pComboOwner->afterLoad, &ComboBoxCellRenderer::createAfterLoadServerCallback, pComboOwner);
ostr << "}";
}
ostr << "})"; // end SimpleStore
ostr << ",displayField:'d',typeAhead:true,triggerAction:'all'";
std::string tooltip (pCell->getToolTip());
if (pComboOwner && pComboOwner->selected.hasJavaScriptCode())
if (pComboOwner && (pComboOwner->selected.hasJavaScriptCode() || !tooltip.empty()))
{
ostr << ",listeners:{";
Utility::writeJSEvent(ostr, EV_SELECTED, pComboOwner->selected, &ComboBoxCellRenderer::createSelectedServerCallback, pComboOwner);
bool written = Utility::writeJSEvent(ostr, EV_SELECTED, pComboOwner->selected, &ComboBoxCellRenderer::createSelectedServerCallback, pComboOwner);
if (!tooltip.empty())
ostr << ",render:function(c){Ext.QuickTips.register({target:c.getEl(),text:'" << Utility::safe(tooltip) << "'});}";
{
if (written)
ostr << ",";
ostr << "render:function(c){Ext.QuickTips.register({target:c.getEl(),text:'" << Utility::safe(tooltip) << "'});}";
}
ostr << "}";
}
else if (!tooltip.empty())
{
ostr << ",listeners:{";
ostr << "render:function(c){Ext.QuickTips.register({target:c.getEl(),text:'" << Utility::safe(tooltip) << "'});}}";
}
ostr << "})";
pCell->beforeLoad += Poco::delegate(&ComboBoxCellRenderer::onLoad);

View File

@@ -69,6 +69,7 @@ void LayoutRenderer::renderLayoutHead(const Layout* pLayout, const RenderContext
// the parent is not a panel
// assume that the direct parent is a panel
ostr << "new Ext.Panel({border:false,bodyBorder:false,";
ostr << "id:'" << pLayout->id() << "',";
renderParameters(pLayout, context, ostr, layoutId, layoutConfig, cols, horPad, vertPad);
ostr << "})";
}
@@ -172,9 +173,9 @@ void LayoutRenderer::visitChildren(const Layout* pLayout, int cols, int horPad,
if (*it)
{
//horizontallayout works only when children are panels
ostr << "new Ext.Panel({border:false,bodyBorder:false,items:";
ostr << "new Ext.Panel({border:false,bodyBorder:false,items:[";
(*it)->renderHead(context, ostr);
ostr << "})";
ostr << "]})";
}
else
ostr << "{}";