This is a migrated thread and some comments may be shown as answers.

detailInit not working

0 Answers 268 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saurav
Top achievements
Rank 1
Saurav asked on 31 Mar 2021, 11:00 AM

On my page i have 2 tabs . First tab contains item with details . On page load details open perfectly . on First tab click , i get the data again .Now details does not open . But on second click on First tab , we get the data again and now i am able to expand the details data again . On each alternate click on the First tab , i am able to get expand details data again

Note : Details expands in debugger mode but only once

 function LoadCustomGrid(CurrentDivID) {
                
            ds = new kendo.data.DataSource({
                type: "odata",
                transport: {
                    read: {
                        url: "../Handler/OrderHandler.ashx?Action=GetETAMissedOrders",
                        type: "POST",                        
                        data: { 'MerchantId': '<%=gMerchantID%>'},
                        complete: function (jqXHR, textStatus) {
                            kendo.ui.progress($("[Id$=" + CurrentDivID + "]"), false);
                            if (textStatus == 'parsererror') {
                                ShowMessage('E', jqXHR.responseText);
                            }
                        }
                    },
                    parameterMap: function (options, operation) {
                        if (operation !== "read" && options.models) {
                            return {
                                models: kendo.stringify(options.models)
                            };
                        }
                        else {
                            return JSON.stringify(options);
                        }
                    }
                },
                schema: {
                    model: {
                        fields: {
                            Age: { type: "string", editable: false },
                            OrderDate: { type: "date", editable: false },
                            OrderID: { type: "string" },
                            ETA: { type: "date", editable: false },
                            PaymentType: { type: "string", editable: false },
                            DeliveryMode: { type: "string" },
                            OrderRefUrl: { type: "string" }
                        }
                    }

                },
                error: function (e) {
                    ShowMessage("E", "Request cannot be served at this time.")
                },
                page: 1,
                pageSize: 20,
                serverPaging: false,
                serverFiltering: false,
                serverSorting: false
            });
            var CustomizedColumns = [];
            if (CurrentDivID == 'divETAMissedGrid') {
                CustomizedColumns = [
                    {
                        field: "Box", title: "<input id='checkAll', type='checkbox', onclick='checkall()' />", width: "5%", filterable: false,
                        template: "<input type=\"checkbox\" id='chk_\#=OrderID#\'  onclick=''/>", menu: false, headerAttributes: { style: "background: none;" }
                    },
                        
                        {
                            field: "OrderID",
                            title: "Order Id",
                            width: "8%",
                            template: '<a target=_blank id=ref_\#=OrderID#\  href=\#=OrderRefUrl#\> \#=OrderID#\ </br> </a> ',
                            filterable: {
                                extra: false, operators: { // redefine the string operators
                                    string: {
                                        eq: "Is Equal To"
                                    }
                                }
                            }
                        },
                         {
                             field: "OrderDate",
                             title: "Order Time",
                             width: "10%",
                             template: "#if(kendo.toString(OrderDate,'dd-MMM-yyyy') =='01-Jan-0001'){#  #}else{# #= kendo.toString(kendo.parseDate(OrderDate), 'd-MMM-yyyy h:mm:ss tt')# #}#",
                             filterable: {
                                 extra: true, operators: { // redefine the string operators
                                     date: {
                                         lte: "Is Befor or Equal To",
                                         gte: "Is After or Equal to"
                                     }
                                 }
                             }
                    },
                         {
                            field: "Age",
                            title: "Order Age",
                            filterable: false,
                            width: "6%"
                        },
                         {
                             field: "ETA",
                             title: "ETA Time",
                             width: "10%",
                             template: "#if(kendo.toString(ETA,'dd-MMM-yyyy') =='01-Jan-0001'){#  #}else{# #= kendo.toString(kendo.parseDate(ETA), 'd-MMM-yyyy h:mm:ss tt')# #}#",
                             filterable: {
                                 extra: true, operators: { // redefine the string operators
                                     date: {
                                         lte: "Is Befor or Equal To",
                                         gte: "Is After or Equal to"
                                     }
                                 }
                             }
                    },
                         {
                            field: "PaymentType",
                            title: "Payment Type",
                            filterable: false,
                            width: "8%"
                    },
                         {
                            field: "DeliveryMode",
                            title: "Delivery Mode",
                            filterable: false,
                            width: "8%"
                        },
              {
                  field: "", title: "Action", width: "8%",
                  template: "<input type=\"button\" class='button_small greyishBtn' value='Update' id='\#=OrderID#\' onclick='UpdateOrderETA(this)'/>", menu: false, headerAttributes: { style: "background: none;" }
              }
                ];

            }
            var datagrid = $("[Id$=" + CurrentDivID + "]").kendoGrid({
                dataSource: ds,
                sortable: false,
                navigatable: true,
                filterable: true,
                columns: eval(CustomizedColumns),
                sorting: false,
                pageable: {
                    pageSizes: [20, 40, 60,80, 100]
                },
                dataBound: function () {
                    $(".tipsyrev").tipsy({ gravity: 's', fade: true, html: 'true' });
                    var grid = $("[Id$=" + CurrentDivID + "]").data("kendoGrid");
                    var count = grid.dataSource.total();
                    if (count == 0) {
                        $(".k-grid table").addClass("activity_datatable");
                    } else {

                        $("[Id$=" + CurrentDivID + "]").show(500);
                        $(".k-grid table").addClass("activity_datatable");
                    }
                     $("tr.k-alt").removeClass("k-alt");
                },
                detailInit: detailInit
            });
            return false;
        }

        function detailInit(e) {
        var schemaJson = [];
            var columnJson = new Array();
            var dsdetail = eval(e.data.ETAmissedItems);
            e.detailCell.html("");

            columnJson.push({ field: "RetransactionId", title: "RetransactionId" , hidden: true });
            columnJson.push({ field: "RedetailsId", title: "RedetailsId" , hidden: true });
            columnJson.push({ field: "Sku", title: "Sku" });
            columnJson.push({ field: "VariantSku", title: "Variant Sku" });
            columnJson.push({ field: "Qty", title: "Quantity" , width: "7%" });
            columnJson.push({ field: "Price", title: "Price" });
            columnJson.push({ field: "ItemETA", title: "ETA Time" ,template: "#if(kendo.toString(ItemETA,'dd-MMM-yyyy') =='01-Jan-0001'){#  #}else{# #= kendo.toString(kendo.parseDate(ItemETA), 'd-MMM-yyyy h:mm:ss tt')# #}#" });
            columnJson.push({
                field: "", title: "Action", width: "10%",
                template: "<input type=\"button\" class='button_small greyishBtn' value='Update'  onclick='UpdateOrderItemETA(\#=RetransactionId#\ , \#=RedetailsId#\ ,  \"#=Sku#\" ,  \"#=VariantSku#\")'/>", menu: false, headerAttributes: { style: "background: none;" }
            });

        $("<div/>").appendTo(e.detailCell).kendoGrid({
            dataSource: { data: dsdetail },
            scrollable: true,
            sortable: true,
            resizable: true,
            columns: columnJson,
            selectable: false,
            sorting: false,
            reorderable: true,
            filterable: {
                extra: false
            },
        });
        }

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Saurav
Top achievements
Rank 1
Share this question
or