views:

274

answers:

1

Hi guys, i was trying to do a Cell Editing based on this documentation http://www.trirand.com/jqgridwiki/doku.php?id=wiki:cell_editing

I have two questions:

  1. How can i get the Index of my row posted to the server: The information i'm getting posted is the following: a) value of the cell b) RowId

The thing is that the rowId doesn't help me. I need the actual Id of the information I'm displaying so i can do the server update with that Id.

colNames: ['Id', 'Codigo', 'Nombre'],

colModel: [ { name: 'Id', index: 'Id', width: 50, align: 'left', hidden: true },

{ name: 'Codigo', index: 'Codigo', width: 55, align: 'left', editable: true, editrules: { number: true} },

{ name: 'Nombre', index: 'Nombre', width: 200, align: 'left' }],

I need the value of the column 'Id' to do my update.

2.I don't understand in the documentation how to manage an error from the server, so I can display the error message.

Thank you very much!

Notes:

a) I've already asked in the forum of trirand, but no one reply it to me.

b) If anyone has done this, it would help if help me pasting the code.

c) I'm working on MVC 2 Asp.net

A: 

Hi,

mostly one you inline editing or form editing and not cell editing. I recommend you to switch to one of the two modern form editing or you

  1. The information RowId is already the value of the column 'Id'. getInd(rowid,false) method returns the index of the row in the grid table specified by id=rowid.
  2. To be able to display error returns from server you needs know the format of data returned from server in the error case. If error returned from server have, for example, JSON format {"Detail":"error text"} (errors from WFC service) you can define loadError parameter of jqGrid like:

    loadError: function(xhr, st, err) { alert(errorTextFormat(xhr)); }

where errorTextFormat function which decode the error massage and can looks like

var errorTextFormat = function (data) {
    var str = data.responseText.substr(0, 10);
    if (str === '{"Detail":') {
        var errorDetail = jQuery.parseJSON(data.responseText);
        var s = "Error: '";
        s += data.statusText;
        s += "'. Details: ";
        s += errorDetail.Detail;
        return s;
    } else {
        var res = "Status: '";
        res += data.statusText;
        res += "'. Error code: ";
        res += data.status;
        return res;
    }
};

The same function you can use to decode errors of row editing (at least inline editing or form editing). ASP.NET MVC returns mostly messages in HTML format so your error decoding function should be another. I don't use cell editing as the most other people do, so can not help you in the case or customizing of the error messages in cell editing.

Oleg
Thanks Oleg, I'll try the inline editting. I was just curius about the cell editing, because i just need only that cell to be editted. But my question is not being answered. How can i send the 'Id' to the server?
Sergio
Oleg