如何设置快速搜索初始值?
我想在哪里放置一个初始值。 我已经看到快速搜索有“q”元素,但我无法访问它,例如,这找不到 q 元素:
$quickSearch->getElement('q');
How can I access the fastsearch to set an initial value?
where I want tu put an initial value.
I have seen that quicksearch has 'q' element but I can't access it, for example this does not find the q element:
$quickSearch->getElement('q');
How can I access the quicksearch in order to set an initial value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看它的来源可以帮助您找到问题。 Agile Toolkit 的设计方式是开发人员应该利用源代码的知识。
QuickSearch 是从 Filter 派生的,而 Filter 是从 Form 派生的,所以应该有 addField 的地方。查看 QuickSearch,您会在recallAll() 函数中找到它。没有对此函数的调用,因此我们应该查看父类 - Filter。
Filter 在 api 中设置一个钩子,在初始化完成后调用recallAll。这意味着要能够访问该字段,您可以重新定义方法或自己添加挂钩。
挂钩:
扩展
最后,您可以利用了解recallAll从何处加载默认值的优势,只需执行以下操作:
Looking at the source of it can help you find things out. Agile Toolkit is designed in a way where developer should take advantage of the knowledge of the source code.
QuickSearch is derived from Filter which is derived from Form, so there should be addField somewhere. Looking at the QuickSearch, you'll find it inside recallAll() function. There are no calls to this functions so we should look into the parent class - Filter.
Filter sets up a hook in api to call recallAll after initialization have been finished. That means to be able to access the field you can either redefine a method or add a hook yourself.
Hook:
Extending
Finally you can take advantage of knowing where recallAll is loading their default values from and simply do this:
为了解决这个问题,我们首先要了解QuickSearch类的Search Field是如何添加到Grid Basic类中的。因此,通过研究源代码,我们可以看到:
q
q 仅添加在网格的渲染阶段
知道这些,我们现在可以继续添加对地址项 #1 的修改。
首先,我们需要添加一个变量来跟踪 QuickSearch 类中的 Form_Field
q
:其次,为了解决第 2 项,在定义网格的页面上,我们需要添加一个后续挂钩,例如:
这将在快速搜索字段旁边设置一个CAPTION,并在搜索字段为空时添加DEFAULT搜索文本。
如果这只是一次性的事情,那么这可能作为一种快速修复很有用,因为直接对库源进行更改是非常不正统的,并且不遵循 ATK 所提倡的扩展和子类化的 OOP 概念。
to address this, we must first understand how the Search Field of the QuickSearch Class is added to the Grid Basic Class. so upon investigation of the source code, we can see that:
q
q
is ONLY added DURING the Rendering phase of the gridknowing these, we can now proceed adding the modifications to address item #1.
first, we need to add a variable to track the Form_Field
q
in the QuickSearch Class:second, to address item #2, on our page where the grid is defined, we need add a follow-up hook, example:
this will set a CAPTION beside the QuickSearch field and add a DEFAULT search text if the search field is empty.
if this is just a one-time thing, then this may be useful as a quick fix because directly making changes to the library source is very unorthodoxed and does not follow the OOP concept of extending and sub-classing as promoted by ATK.