Initialize datagrids when whole datagrid is loaded in snippet
When using datagrid-full.js from cdn what's easiest way to init datagrid when it's loaded through naja? When opening page like full refresh evertything works fine, quick edits and everything, but when it's loaded through ajax looks like js is not initialized... How can I init datagrid through naja.addEventListener?
Try to call createFullDatagrids
👀 See https://github.com/contributte/datagrid/blob/master/assets/datagrid.ts#L211
Tried that, but it's not available in full datagrid js... Only way to do this is to do custom build... @radimvaculik
Well, I think you need to switch to a custom build.
I already switched, but this should be available in datagrid-full.js IMHO... I'll test when on project-...
@dakorpar Could you draft a PR?
@dakorpar What are the changes?
@dakorpar What are the changes?
I just tried with your datagrid-full.js and added this:
<script n:syntax="off">
class NajaDatagridExtension{
initialize(naja) {
naja.addEventListener('complete', (params) => {
createDatagrids(new NajaAjax(naja), {
datagrid: {
plugins: [
new AutosubmitPlugin(),
new CheckboxPlugin(),
new ConfirmPlugin(),
new InlinePlugin(),
new ItemDetailPlugin(),
new EditablePlugin(),
new NetteFormsPlugin(netteForms),
new SortablePlugin(new SortableJS()),
new DatepickerPlugin(new VanillaDatepicker({ buttonClass: 'btn', language: 'cs' })),
new SelectpickerPlugin(new TomSelect(Select)),
new TreeViewPlugin(),
],
},
});
});
}
}
naja.registerExtension(new NajaDatagridExtension());
</script>
That was just to try it out, but I already switched to custom build...
TBH I think this should just be included in datagrid-full.js...