But i think its bit slow. Is there other better ways to implement the same?

KrishNik

Answers

I'm not sure it's the parsing that's slowing you down. It could be that you're running a lot of jQuery selectors on a lot of objects, which can take time.

EDIT: Saw @pointy's answer. I didn't even notice that you were doing event delegation via DOM attributes. Yeeaah, that would probably run pretty slowly.

In fact, using live event delegation instead of assigning a click event to every single element would probably run even faster. Start by, instead of giving it the click event, give the element a reference to the object in question using jQuery's data function.

case 'status':
// Note that I switched it to this[j], since I suspect
// using this.j was unintentional
var val=(this[j])?'active.gif':'deactive.gif';
$('#td_'+i+'_'+j).find('img').attr('src', '<?= base_url() ?>assets/grid/images/'+val).
data('status_obj', obj);

Then, run the following only once in your entire script (obviously, untested).

Note that I renamed some variables. You were reusing variable names for different things, like reusing the data variable containing the JSON string to contain the parsed data, and the obj variable that contains the parsing result to contain a single item from the data.

I notices that you are using this.j at one point in the code. This is not the same as item[j] but item['j'], which might not be what's intended.