Homepage
Main navigation
Main content
Additional information
October Tricks
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
October CMS resources and help articles
Simple and to the point. Optimized by the community.
×
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Edit trick
Changes will be published after manual review
Title
Give your trick a describing title. Do
not
start with «How to...».
Your trick
Keep it short and concise! Markdown is supported.
I have reportController and for more filter use talglist for form but some models have many records(20,000 or more) and take much time to load all data for report so I use my custom taglist and ajax request for loading data. 1- In yourNamepace/yourPlugin/models/YourModel/report.yaml ``` test: type: partial path: customtags ``` 2- In yourNamepace/yourPlugin/controllers/reportcontrollers/ Create _customtags.htm In this file ``` <select id="tags" style="width:200px" name="data[]"></select> <script> $(document).ready(function () { $("#tags").select2({ multiple: true, ajax: { dataType: 'json', delay: 250, url: function (params) { return 'http://localhost/anbar/kalas/' + params.term; }, data: function (params) { let query = { search: params.term, }; // Query parameters will be ?search=[term]&type=public // return query; return query; }, processResults: function (data, page) { console.log(data); // parse the results into the format expected by Select2. // since we are using custom formatting functions we do not need to // alter the remote JSON data return { results: data }; }, // cache: true }, escapeMarkup: function (markup) { return markup; }, minimumInputLength: 1, templateResult: formatRepo, templateSelection: formatRepoSelection }); function formatRepo(repo) { if (repo.loading) return repo.text; var markup = '<div>' + repo.name + '</div>' ; markup += '</div></div>'; return markup; } function formatRepoSelection(repo) { return repo.name || repo.text; } }); </script> ``` 3- In plugin create routes.php and get data from your model like this example ``` Route::get('/kalas/{name}', function ($name) { $query = substr($name, strpos($name, '?')); $kalas = \Ehsan\Anbar\Models\Kala::where('name', 'like', '%' . $query . '%') ->select(['id','name']) ->get() ->toJson(); return $kalas; }); ``` and thanks @LarryB and @OFFLINE
References
Add additional online resources to your trick
×
Name
URL
×
Name
URL
+ Add reference
Topics
If your trick fits more than one topic select multiple. Select at least one.
Backend
Plugin Development
CMS
Twig
Themes
Deployment
Tags
You can use existing tags or create new ones. Add at least one.
Submit for review
Cancel
We use cookies to measure the performance of this website. Do you want to accept these cookies?
Accept
Decline