Wireup events when importing configuration

Dec 12, 2012 at 4:43 AM

Hi

Im importing my grid configuration like this (taken from your example):

JqGridConfiguration configuration = null;
            //Do we already have configuration in Session
            if (Session[id] != null)
                //If yes, the use it
                configuration = (JqGridConfiguration)Session[id];
            else
            {
                //If no, then create one
                configuration = new JqGridConfiguration()
                {
                    Settings = new JqGridOptions<LanguageViewModel>(id)
                    {
                        ColumnsRemaping = new List<int>() { 0, 1, 2, 3},
                        RowsNumber = 10,
                        SortingName = "Name",
                        SortingOrder = JqGridSortingOrders.Asc,
                        ViewRecords = true,
                        Caption = "Sprog",
                        
                    }
                };
            }

            //Those settings should be set always "just in case"
            configuration.Settings.Url = Url.Action("ReadData", "Language", new{area="Administration"});
            configuration.Settings.DataType = JqGridDataTypes.Json;
            configuration.Settings.MethodType = JqGridMethodTypes.Post;
            configuration.Settings.Pager = true;
            configuration.Settings.HiddenEnabled = false;
            configuration.Settings.AutoWidth = true;
            configuration.Settings.GridComplete = "windowsBinding";

            return new JqGridJsonResult() { Data = configuration, JsonRequestBehavior = JsonRequestBehavior.AllowGet };

but the GridComplete binding does not work.

Where to but this binding?

Coordinator
Dec 12, 2012 at 11:12 AM

Hi,

Unfortunately the callback and events can't be transfered with the configuration, they need to be bound on client side. This can be done in two ways. You can set the callback with setGridParam method:

<script type="text/javascript">
    $(document).ready(function () {
        $('#products').jqGridImport({
            ...
            importComplete: function () {
                ...
                $('#products').jqGrid('setGridParam',{ gridComplete: windowsBinding });
            }
        });
    });
</script>

As an alternative (since jqGrid v4.3.2) you can bind to the raised events with jQuery (in case of gridComplete this is better as you can be sure that you have bound the event before it occurs):

<script type="text/javascript">
    $(document).ready(function () {
        $('#products').on('jqGridGridComplete', windowsBinding);
        $('#products').jqGridImport({
            ...
        });
    });
</script>

Dec 13, 2012 at 2:00 AM

Thank you for at fast reply.