Hi, All :)
I want to report an error I've come across today while trying to use DataTable.
I currently use koolreport/datagrid@8.0.1 and get the following error when I use DataTable:
TypeError: Cannot read properties of undefined (reading 'ConvertToClientFunction'
at my-own-report:2233:35
at KoolReport.js:105:25
at Array.forEach (<anonymous>)
at Object.checkScriptsAndCallback (KoolReport.js:102:20)
at Object.onScriptLoaded (KoolReport.js:88:14)
I think KoolReport object in DataTables.tpl.php:249 in the following does not have helper property, thereby calling ConvertToClientFunction from it causes error.
<?php } else { ?>
<script type="text/javascript">
    KoolReport.widget.init(
        <?php echo json_encode($this->getResources()); ?>,
        function() {
            <?php $this->clientSideBeforeInit(); ?>
            var name = '<?php echo $uniqueId; ?>';
            var dtOptions = <?php echo ($this->options == array()) ? "" : Util::jsonEncode($this->options); ?>;
            var fastRender = <?php echo $this->fastRender ? 1 : 0; ?>;
            if (fastRender) {
                var dataRows = <?php echo json_encode($this->dataRows); ?>;
                dtOptions.data = dataRows;
                // <?php echo $uniqueId; ?>_data.dataRows = dataRows;
            }
            window[name + '_state'] = {};
            // >>> Here <<<
            KoolReport.helper.ConvertToClientFunction.call(dtOptions, dtOptions);
            // >>> Here <<<
            var dt = window[name] = $('#' + name).DataTable(dtOptions);
            dt.registerEvent = dt.on;
            var <?php echo $uniqueId; ?>_data = {
                name: '<?php echo $uniqueId; ?>',
                id: '<?php echo $uniqueId; ?>',
                searchOnEnter: <?php echo $this->searchOnEnter ? 1 : 0; ?>,
                searchMode: <?php echo json_encode($this->searchMode); ?>,
                serverSide: <?php echo $this->serverSide ? 1 : 0; ?>,
                serverSideInstantSearch: <?php echo $this->serverSideInstantSearch ? 1 : 0; ?>,
                overrideSearchInput: <?php echo $this->overrideSearchInput ? 1 : 0; ?>,
                rowDetailData: dtOptions.rowDetailData,
                showColumnKeys: <?php echo json_encode($showColumnKeys); ?>,
                columns: <?php echo json_encode($this->columns); ?>,
                editButtons: <?php echo json_encode($this->editButtons); ?>,
                editUrl: '<?php echo Util::get($this->params, "editUrl"); ?>',
                fastRender: fastRender,
                rowDetailIcon: <?php echo $this->rowDetailIcon ? 1 : 0; ?>,
                rowDetailSelector: '<?php echo $this->rowDetailSelector; ?>',
                clientRowSpanColumns: <?php echo json_encode($this->clientRowSpanColumns); ?>,
                themeBase: '<?php echo $this->getThemeBase(); ?>',
            };
            <?php echo $uniqueId; ?>_data.rawData = <?php echo json_encode($this->rawData); ?>;
            KR<?php echo $uniqueId; ?> = KoolReport.KRDataTables.create(
                <?php echo $uniqueId; ?>_data);
            <?php if ($this->clientEvents) {
                foreach ($this->clientEvents as $eventName => $function) { ?>
                    dt.on("<?php echo $eventName; ?>", <?php echo $function; ?>);
            <?php }
            } ?>
            <?php $this->clientSideReady(); ?>
        }
    );
</script>
<?php } ?>
It happens even when I use Datatable in a very simple case as it follows:
    DataTables::create(
        [
            "dataSource" => $data,
        ]
    );
So, it should be fairly easy to reproduce this error.
Once I downgrade a version of koolreport/datagrid to "7.9.1", everything start working again without the above error.
Thank you :)