Skip to content

Replies

0
Tung
Tung answered on Oct 16, 2014 9:38 PM

It works. Finally.

Thank you for your support and help.

0
Tung
Tung answered on Oct 15, 2014 7:03 PM

I did download and run it, it woks. However if I checked and unchecked some checkbox, when I ran the getGridCheckBoxesValues() function I still get the old value

Example:

I add <input type="button" onclick="getGridCheckBoxesValues()"; value="Validate" /> on the html

Load the page with columnA: false, true, false. Now make change to columA to: true, false true.

ColumnA is <input checkbox> so the user can checked and unchecked the box

Click on "Validate" button,  it call onclick="getGridCheckBoxesValues()"; it loop through all the rows, but the columnA still return:false, true, false instead of true, false true

0
Tung
Tung answered on Oct 13, 2014 4:56 PM

Thanks. I did read through each link above and try it but when I check on different checkbox it still return false and it does not go to my debug code

Here is what I put in my code. Please help and can you give some example like you did up there

var checkboxtemplatediv = "<input class='gridcheckboxinput' type='checkbox' {{if ${HasAccess} === \"true\"}} checked=\"checked\"{{else}}off{{/if}} />"; function GetDivisionAccessList(vType, EmployeeID) {     $.post("../Admin/GetPTASUserAccess", {vType:vType, EmployeeID: EmployeeID }, function (data) {                 $("#igGridDiv").igHierarchicalGrid('destroy');         $("#igGridDiv").igHierarchicalGrid({             height: "300px",             width: "100%",             autoGenerateColumns: false,             primaryKey: "DepartmentID",             expandColWidth: 0,             renderCheckboxes: true,             rowTemplate: "<tr><td><input class='gridcheckboxinput' type='checkbox' {{if ${HasAccess} === \"true\"}} checked=\"checked\"{{else}}off{{/if}}></td><td class='gridtextinput'>${DepartmentDescription}</td><td>${DepartmentID}</td><tr>",             columns: [                         { key: "HasAccess", headerText: "&nbsp;Access", dataType: "bool", width: "10%", height: "12px", template:checkboxtemplatediv},                         { key: "DepartmentDescription", headerText: "&nbsp;Division Name", dataType: "string", height: "12px", template: "<div class='gridtextinput' style='height:12px;'>${DepartmentDescription}</div>" },                         { key: "DepartmentID", headerText: "DepartmentID", dataType: "string", width: "0%", height: "12px", template: "<div class='gridtextinput' style='height:0px;'>${DepartmentID}</div>", hidden: true }                       ],             dataSource: data,             dataSourceType: "json",             responseDataKey: "results",             features: [                     {                         name: "Selection",                         mode: "row",                         multipleSelection: true,                         activation: true ,                         columnSettings: [                             {                                 classes: "gridtextinput"                             }                         ]                     },                     {                         name: "Sorting",                         type: "local",                         sortUrlKey: "sort",                         sortUrlKeyAscValue: "asc",                         sortUrlKeyDescValue: "desc",                         columnSettings: [{                             columnIndex: -1,                             allowSorting: true,                             columnKey: "DepartmentID"                      },                                           {                             columnIndex: -1,                             allowSorting: true,                             columnKey: "DepartmentDescription"                         }]                     }                 ]         });     });

}

 

$(

"#igGridDiv").on("iggridcellclick", function (event, args) {

   

var dataSource = args.owner.dataSource, rowid = args.rowKey, col = args.colKey;

   

// check if the target of the click is checkbox

//    if ($(event.originalEvent.target).is("input[type=checkbox]")) {

//        // check if the checkbox is checked and the dependent row checkbox is not checked

//        if ($(event.originalEvent.target).attr("checked"))

//        {

//            var dependId = $(event.originalEvent.target).attr("data-depend-id");

//            var dependCheckbox = $("#igGridDiv").find("input[data-id='"+ dependId +"']")[0];

//            // if the dependent checkbox is checked the we need to uncheck current(this) checkbox

//            if ($(dependCheckbox).attr("checked"))

//            {

//                // warn the user and uncheck the checkbox

//                alert("Invalid option!");

//                $(event.originalEvent.target).removeAttr("checked");

//            }

//            else

//            {

//                //commit current selection to the data source. igGridUpdating needs to be configured

// $("#igGridDiv").igGridUpdating("setCellValue", rowid, col, args.cellElement.checked);

//                dataSource.commit(); // not necessary if autoCommit is true

//            }

//        }

//    }

   

var editor = $("#igGridDiv").igGridUpdating("editorForKey", "Selected");

   

if (editor != null && editor.data("igEditorFilter"))

       

var value = editor.data("igEditorFilter").options.provider.value;

 

});

 

0
Tung
Tung answered on Oct 10, 2014 8:44 PM

Here is my code

$("#igGridDepartment").igHierarchicalGrid({             height: "300px",             width: "100%",             autoGenerateColumns: false,             primaryKey: "DepartmentID",             expandColWidth: 0,             columns: [                         { key: "HasAccess", headerText: "&nbsp;Access", dataType: "bool", width: "10%", height: "12px", template:checkboxtemplatedept},                         { key: "DepartmentDescription", headerText: "&nbsp;Department Name", dataType: "string", height: "12px", template: "<div class='gridtextinput' style='height:12px;'>${DepartmentDescription}</div>" },                         { key: "DepartmentID", headerText: "DepartmentID", dataType: "string", width: "0%", height: "12px", template: "<div class='gridtextinput' style='height:0px;'>${DepartmentID}</div>", hidden: true }                       ],             dataSource: data,             dataSourceType: "json",             responseDataKey: "results",             features: [                     {                         name: "Selection",                         mode: "row",                         multipleSelection: true,                         activation: true,                         columnSettings: [                             {                                 classes: "gridtextinput"                             }                         ]                     },                     {                         name: "Updating",                         enableAddRow: false,                         editMode: "row",                         enableDeleteRow: false,                     },                     {                         name: "Sorting",                         type: "local",                         sortUrlKey: "sort",                         sortUrlKeyAscValue: "asc",                         sortUrlKeyDescValue: "desc",                         columnSettings: [{                             columnIndex: -1,                             allowSorting: true,                             columnKey: "DepartmentID"                      },                                           {                             columnIndex: -1,                             allowSorting: true,                             columnKey: "DepartmentDescription"                         }]                     }                 ]         });

0
Tung
Tung answered on Oct 10, 2014 7:55 PM

I also try this, but it always return false

//Loop through each row in the div grid.

    $grid = $("#igGridDiv");

    rows = $grid.igGrid("allRows");

    $.each(rows,function (index, row) {

        rowId = $(row).attr("data-id"); // This attribute stores the row's primary key.

        alert($grid.igGrid(getCellValue", rowId, "HasAccess"));

    });

 

it is very urgent. thanks

0
Tung
Tung answered on Oct 10, 2014 4:40 PM

Here is how I set my grid

var checkboxtemplatediv = "<input class='gridcheckboxinput' type='checkbox' {{if ${HasAccess} === \"true\"}} checked=\"checked\"{{else}}off{{/if}} />";

columns: [

                        { key:"HasAccess", headerText: "&nbsp;Access", dataType: "bool", width: "10%", height: "12px", template:checkboxtemplatediv},

                        { key:"DepartmentDescription", headerText: "&nbsp;Division Name", dataType: "string", height: "12px", template: "<div class='gridtextinput' style='height:12px;'>${DepartmentDescription}</div>" },

                        { key:"DepartmentID", headerText: "DepartmentID", dataType: "string", width: "0%", height: "12px", template: "<div class='gridtextinput' style='height:0px;'>${DepartmentID}</div>", hidden: true }

                      ],

0
Tung
Tung answered on Oct 10, 2014 4:33 PM

Thanks for your help.

I have another questions.

After the grid display, the user can check/unchecked the checkbox (checkbox is <input type='checlbox')

How do I loop through the grid and find if the checkbox value is check or uncheck.

This is what I did but it does not work.

var rows = $('#igGridDiv').igGrid('rows');  

for (i = 0; i < rows.length; i++) {

     var hasaccess = rows[i].cells[0].innerText;

     }

HasAccess always return empty

 

Please help