Skip to content

Update specific row from javascript #1111

@usingh075

Description

@usingh075

I am displaying a grid like this and I have a button. Every time I click this button I want update a specific row lets say with ID:5

$("#clickme").click(function (e) {
//logic to update row with ID 2

});

var clients = [];
for(var i=1;i<=10;i++) {
var client = {ID: i, "Name": "Otto Clay" + i, "Age": 25, "Country": 1, "Address": "Ap #897-1459 Quam Avenue", "Married": false };
clients.push(client);
}

var countries = [
    { Name: "", Id: 0 },
    { Name: "United States", Id: 1 },
    { Name: "Canada", Id: 2 },
    { Name: "United Kingdom", Id: 3 }
];

$("#jsGrid").jsGrid({
    width: "100%",
    height: "400px",

    inserting: true,
    sorting: true,
    paging: true,
    pageIndex: 1,
    pageSize: 10,

    data: clients,
    controller:{
        updateItem: function(item) {
            console.log(item);
        }
    },
    fields: [
        { name: "Name", type: "text", width: 150, validate: "required" },
        { name: "Age", type: "number", width: 50 },
        { name: "Address", type: "text", width: 200 },
        { name: "Country", type: "select", items: countries, valueField: "Id", textField: "Name" },
        { name: "Married", type: "checkbox", title: "Is Married", sorting: false },
        { type: "control" }
    ]
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions