KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Laravel and Drilldown #2047

Open Aljaz Ketis opened this topic on on Apr 26 - 5 comments

Aljaz Ketis commented on Apr 26

I have a laravel project and i use your Koolreport Pro package and i want to display a drilldown view, so basically a amazing Card and on click I want to display a basic Table. I see that the Post Method is called, but there is a mismattch in CSRF tokens, so i googled it and found that there is an issue and how to resolve it on this forum (https://www.koolreport.com/forum/topics/1356), but it didn't work.. i need help. And another question or improvement, is it possible to add custom icon or an .svg of your own as the card icon?

Sebastian Morales commented on Apr 26

Pls open your browser's dev tool (F12), tab Network -> XHR to catch ajax request. Then perform drilldown action and see if the xhr request contains CSRF token or not?

Aljaz Ketis commented on Apr 26

It is not set, that is the source of my problem, even if I add the Ajax configuration at top, it is still not included. Why can't i incude other params and _token like you can do on PivotMatrix with:

"scope"         => array(
                    "_token"   => csrf_token(),
                    "other_params" => "example"
)
Sebastian Morales commented on Apr 27

Pls add this meta tag to your page's head and this code to your page (after jQuery link or widget render):

<meta name="csrf-token" content="<?php echo csrf_token(); ?>" />
...
<script type="text/javascript">
$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});
console.log("Finished ajax setup CSRF");
</script> 

Then check your browser's dev console to see if "Finished ajax setup CSRF" is in output. Tks,

Aljaz Ketis commented on Apr 28

Yet another work-around, but how can you add additional params when the ajax call is executed, becouse I need them for other parts of the report?

Sebastian Morales commented on Apr 29

If the widgets you use don't support "scope" property, which add parameeters to ajax request, you could set ajax request's default data with these javascript codes:

<script>
		// Add another data item to the global configuration
		$.ajaxSetup({
			data: {
				paramName: paramValue,
				...
			}
		});
</script>

or:

$.ajaxSetup({
  beforeSend: function(jqXHR, settings) {
    settings.data = $.extend(settings.data, {paramName: paramValue});
    return true;
  }
});

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
bug
help needed

DrillDown