1

我有一个复选框,单击时会显示一个下拉列表。我只是希望他们改变立场。

问题是当我使用 php 更改位置时,它会引发 ajax 错误。由于每个都在动态 div id 中调用,因此我不能真正使用 CSS 来更改它。

我已经研究过在 css 中使用 nth-child 创建一个上边距,但也没有运气。

现在,复选框切换下拉列表的可见性,但复选框位于下拉列表显示的下方。我想另一种方法是以某种方式使用 javascript ......我错过了什么吗?为什么不能换单

    $ret['reclength'] = new QListBox($objParent);
    $ret['length']->Name = _sp('Item Name');

    $ret['length']->AddItem("weekly", "7");
    $ret['length']->AddItem("bi-weekly","14" );
    $ret['length']->AddItem("Monthly","30" );
    $ret['length']->Display=false;      

    $ret['checkbox'] = new QCheckbox($objParent);
    $ret['checkbox']->Name = _sp('checkbox name');
    $ret['checkbox']->AddAction(new QClickEvent(), new QToggleDisplayAction($ret['length']));

    return $ret;
4

2 回答 2

0

我不确定您的模板文件是什么样子,可能存在乱序问题,因为在那里正确排序它们会改变它的显示顺序。但即使没有这些,您也可以对它们进行订购。只需使用z-index并向 QListbox 添加一个 Css 类:

$ret['length']->CssClass = "mydropdown";

这对CSS:

.mydropdown {
    z-index: 9999;
}

但也有一个带有z-index的 IE6/7 错误

于 2012-11-26T08:08:04.127 回答
0

The rendering order will depend on your controls parent, in your case $objParent. If $objParent is a QForm then you will just need to switch their order in the QForms template. However with the behavior you are witnessing I am assuming that $objParent is a QPanel. If that is the case you will need to add a template to the QPanel and render your controls in that template in the order you desire. You could try AutoRenderChildren = true, but that will render the controls in the order in which they are delegated as children of the QPanel.

To use CSS to position you may want to add an id to the control. That way you can reference it in your CSS and avoid any ambiguity in your selector. You just need to add a second parameter to the constructor like

$ret['reclength'] = new QListBox($objParent, "myControlId");

Just make sure that the myControlId is unique for the page. then you can access in css using #myControlId.

Another option which may work is to set the parent to $this when you instantiate the QListBox control and then after instantiating the QCheckbox set the parent of the QListBox to $objParent. Haven't tested this but it should work. You cann see an example of QForms in action on the QCubed Examples site. The code would look something like this. Note this is untested but should work.

$ret['reclength'] = new QListBox($this);
$ret['length']->Name = _sp('Item Name');

$ret['length']->AddItem("weekly", "7");
$ret['length']->AddItem("bi-weekly","14" );
$ret['length']->AddItem("Monthly","30" );
$ret['length']->Display=false;      

$ret['checkbox'] = new QCheckbox($objParent);
$ret['checkbox']->Name = _sp('checkbox name');
$ret['checkbox']->AddAction(new QClickEvent(), new QToggleDisplayAction($ret['length']));

$ret['reclength']->SetParentControl($objParent);

return $ret; 
于 2013-02-06T13:47:05.167 回答