Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
320
Add custom ajax data when creating, update, delete or get from datasourceurl
posted

Hello, Iam using ASP MVC5 with IgniteUI 2016.2.

How can I add custom data like token or other data when IgniteUI do some ajax to my controller?

Parents
  • 2155
    Offline posted

    Hello,

    If you wish to add some tokens to DataSourceUrl, you may want to use igGrid’s dataSourceObject method.

    The following is an example to add a parameter to DataSourceUrl at runtime.

    --------------------
            var queryString = $('#grid1).igGrid('dataSourceObject');
            $('#grid1).igGrid('dataSourceObject', queryString + "?myParameter=XXXX");

            $('#grid1).igGrid('dataBind');

            //Clear the parameter. 
            $('#grid1).igGrid('dataSourceObject', queryString);
    --------------------

    dataSourceObject method
    http://igniteui.com/help/api/2016.2/ui.iggrid#methods:dataSourceObject


    In order to add a parameter to UpdateUrl which is used when grid’s data is updated(added or removed), you have access to updateUrl string from the grid’s dataSource.settings like below.

    --------------------
                    var strUpdateUrl = $("#grid1").data("igGrid").dataSource.settings.updateUrl;
                    $("#grid1").data("igGrid").dataSource.settings.updateUrl = strUpdateUrl + "?myParameter=XXXX";
     
                    $("#grid1").igGrid("saveChanges");

                    //Clear the parameter.
                    $("#grid1").data("igGrid").dataSource.settings.updateUrl = strUpdateUrl;
    --------------------

    Thank you,
    Mihoko Kamiishi

Reply Children