mardi 26 juillet 2016

Kendo Grid multiselect checkboxes

I have a Treeview. On selecting the edit of the treenode a kendo grid for Roles will be displayed and few textboxes(where is edit other properties for roles). The kendo grid for roles have checkboxes and Rolenames. My current code is working if i select one checkbox. What i need is how i get the array of the ids of the roles if i check multiple checkboxes. Tried multiple ways but not getting the list of ids when multiple checkboxes are selected.On click edit of the node EditNode is triggered and on click of save the 'click' is trigerred. Below is code can anyone help me with this asap.

Thanks

function editNode(itemid) {
var editTemplate = kendo.template($("#editTemplate").html());
var treeview = $("#treeview").data("kendoTreeView");
var selectedNode = treeview.select();
var node = treeview.dataItem(selectedNode);

$("<div/>")
    .html(editTemplate({ node: node }))
    .appendTo("body")
    .kendoWindow({
        title: "Node Details",
        modal: true,
        open: function () {
            console.log('window opened..');
            editDS = new kendo.data.DataSource({
                schema: {
                    data: function (response) {
                        return JSON.parse(response.d); // ASMX services return JSON in the following format { "d": <result> }. 
                    },
                    model: {// define the model of the data source. Required for validation and property types.
                        id: "Id",
                        fields: {
                            Id: { editable: false, nullable: false, type: "string" },
                            name: { editable: true, nullable: true, type: "string" },
                            NodeId: { editable: false, nullable: false, type: "string" },
                        }
                    },
                },
                transport: {
                    read: {
                        url: "/Services/http://ift.tt/2a4DoIR",
                        contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
                        type: "POST", //use HTTP POST request as the default GET is not allowed for ASMX
                        datatype: "json",
                    },
                }
            });

            rolesGrid = $("#kgrid").kendoGrid({
                dataSource: editDS,
                height: 150,
                pageable: false,
                sortable: true,
                binding: true,
                columns: [
                       {
                           field: "name",
                           title: "Rolename",
                           headerTemplate: '<span class="tbl-hdr">Rolename</span>',
                           attributes: {
                               style: "vertical-align: top; text-align: left; font-weight:bold; font-size: 12px"
                           }
                       },

                    {
                        template: kendo.template("<input type='checkbox' class = 'checkbox' id='chkbx' data-id='#:Id #' />"),
                        attributes: {
                            style: "vertical-align: top; text-align: center;"
                        }
                    },
                ],

            }).data('KendoGrid');
        },

    })
 .on("click", ".k-primary", function (e) {
     var dialog = $(e.currentTarget).closest("[data-role=window]").getKendoWindow();
     var textbox = dialog.element.find(".k-textbox");
     var LinKLabel = $('#LL').val();
     var roles = $(chkbx).data('roleid');
     console.log(PageLocation);
     node.text = undefined;
     node.set("LINK_LABEL", LinKLabel);
     node.set("Roles", roles);
     dialog.close();
     var treenode = treeview.dataSource.get(itemid);
     treenode.set("LINK_LABEL", LinKLabel);
     treenode.set("id", Id);
     treenode.set("roles", roles);
     treenode.LINK_LABEL = LinKLabel;
     treenode.ID = Id;
     treenode.roles = roles;

     var rid = $(chkbx).data('roleid');

     $.ajax({
         url: "/Services/http://ift.tt/2aiF98U",
         contentType: "application/json; charset=utf-8",
         type: "POST",
         datatype: "json",
         data: JSON.stringify({ "erpLinksJson": treenode })
     });
     console.log(JSON.stringify(treenode));
 })
  }




Aucun commentaire:

Enregistrer un commentaire