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
1355
loop all record of igHierarchicalGrid and get column of child record
posted

hi, please help me!

i have a igHierarchicalGrid here!

var reportTemplate = data.ReportTemplate;

                            $("#grdReportTemplate").igHierarchicalGrid({
                                //initialDataBindDepth: 1,
                                dataSource: reportTemplate,
                                //dataSourceType: "json",
                                //responseDataKey: "d",
                                autoGenerateColumns: false,
                                primaryKey: "RecordID",
                                width: "100%",
                                height: "500px",
                                renderCheckboxes: true,
                                columns: [
                                    { headerText: "RecordID", key: "RecordID", width: "50px", dataType: "number", hidden: true },
                                    { headerText: "ReportID", key: "ReportID", width: "130px", dataType: "number", hidden: true },
                                    { headerText: "ParentReportID", key: "ParentReportID", width: "50px", dataType: "number", hidden: true },
                                    { headerText: "Select", key: "IsChecked", width: "80px", dataType: "bool" },
                                    { headerText: "ReportDsc", key: "ReportDsc", width: "130px", dataType: "string" },
                                    { headerText: "ReportFileName", key: "ReportFileName", width: "50px", dataType: "string", hidden: true },
                                    { headerText: "Object Type", key: "ObjectType", width: "50px", dataType: "number", hidden: true }
                                ],
                                autoGenerateLayouts: false,
                                defaultChildrenDataProperty: "oReport",
                                columnLayouts: [
                                {
                                    name: "oReport",
                                    childrenDataProperty: "oReport",
                                    //autoGenerateColumns: false,
                                    responseDataKey: "oReport",
                                    primaryKey: "RecordID",
                                    ForeignKey: "ParentReportID",
                                    renderCheckboxes: true,
                                    columns: [
                                            { headerText: "RecordID", key: "RecordID", width: "50px", dataType: "number", hidden: true },
                                            { headerText: "ReportID", key: "ReportID", width: "130px", dataType: "number", hidden: true },
                                            { headerText: "ParentReportID", key: "ParentReportID", width: "50px", dataType: "number", hidden: true },
                                            { headerText: "Select", key: "IsChecked", width: "80px", dataType: "bool" },
                                            { headerText: "ReportDsc", key: "ReportDsc", width: "400px", dataType: "string" },
                                            { headerText: "ReportFileName", key: "ReportFileName", width: "50px", dataType: "string", hidden: true },
                                            { headerText: "Object Type", key: "ObjectType", width: "50px", dataType: "number", hidden: true }
                                    ],
                                    features: [
                                           {
                                               name: "Updating",
                                               enableAddRow: false,
                                               editMode: "row",
                                               enableDeleteRow: false,
                                               showDoneCancelButtons: false,
                                               columnSettings: [
                                                   { columnKey: "IsChecked", editorOptions: { type: "bool", disabled: false } },
                                                   { columnKey: "ReportDsc", editorOptions: { type: "string", disabled: true } }
                                               ]
                                           }],
                                }
                                ],
                                features: [
                                           {
                                               name: "Updating",
                                               enableAddRow: false,
                                               editMode: "row",
                                               enableDeleteRow: false,
                                               showDoneCancelButtons: false,
                                               columnSettings: [
                                                   { columnKey: "IsChecked", editorOptions: { type: "bool", disabled: false } },
                                                   { columnKey: "ReportDsc", editorOptions: { type: "string", disabled: true } }
                                               ]
                                           }],
                            });

i loop all record of grid to get ReportID if column IsChecked= true but i can not get child record of grid

updates1 = $.extend({}, grid1.data('igGrid').pendingTransactions());
                var lsTemplateChecked = "";

                $.each(updates1, function (index, transaction) {
                    switch (transaction.type) {
                        case "row":
                            if (transaction.row.IsChecked == true && transaction.row.ObjectType == 1) {
                                if (lsTemplateChecked == "") {
                                    lsTemplateChecked = transaction.row.ReportID;
                                } else {
                                    lsTemplateChecked = lsTemplateChecked + "," + transaction.row.ReportID;
                                }
                            }

                            break;
                    }
                });

How can i get column of igHierarchicalGrid above?

Thanks you very much!!

Parents
  • 15320
    Offline posted

    Hello Cuong,

    You may get the desired column of the child grid using some of the following API methods: columnByKey or columnByText 

    As you need to specify the correct selector for the child grid in order these methods to return the child grid columns, not the parent one. In order to get the child grid container id, you may inspect the child grid table on the client using browser's developer tools. 

    If you need further assistance, please let me know.

    Regards,

    Tsanna

Reply Children