jhhb01 / silverstripe_ajax_dropdown
在下拉列表中使用Ajax处理大量数据集
dev-master
2024-04-29 13:12 UTC
This package is auto-updated.
Last update: 2024-09-29 13:56:46 UTC
README
一个通过Ajax加载结果的silverstripe下拉列表,用于处理大量数据集
示例用法(稍后我将更好地记录此内容)
// Define a callback to load the results, don't worry about pagination of limiting here $dataSource = function ($term = null) { return SomeDataObject::get()->filter(['Title:PartialMatch' => $term]); }; // Here ID and Title are optional as they are the defaults, they are the names of the columns to // pull the ID and Text of the dropdown option from $field = AjaxDropdownField::create('LabelID', 'Label', 'ID', 'Title'); // This is the only required function call, of course feel free to just chain this on after ::create(...) $field->setSource($dataSource); // These methods are totally optional, I'm going to call them with their defaults below $field->setIDColumn('ID'); // Set the name of the column to pull the dropdown options ID from $field->setTextColumn('Title'); // Set the name of the column to pull the dropdown options text from $field->setMinLength(1); // Set the number of characters that must be entered before a search will be performed $field->setPageLength(150); // Set the number of results that will be returned on each search or "load more" // Each of the above methods also has an associated "getter" e.g. $field->getPageLength();
其他方法
此字段扩展了DropdownField
,因此您可以在此处调用任何可调用的方法,例如setEmptyString()
。
其他模块
此字段应与大多数其他模块一起工作,我已明确测试过与sheadawson/silverstripe-quickaddnew的兼容性。