Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
problems with custom checkbox formatter
05/09/2012
08:34
Avatar
jari.haikonen
New Member
Members
Forum Posts: 2
Member Since:
05/09/2012
sp_UserOfflineSmall Offline

Hi,

I tried to make my own checkbox formatter (because I need value 0 checkboxes to be disabled and value >0 to be enabled etc) and countered a problem with getCell & multiselect.. oh well actually the problem is with getCell if I got it right. Anyway, I made a simple demo where you can see that if any of the checkboxes on the grid is selected, the "get row 1 checkbox value" gets 'yes', and with any I mean the select row checkboxes too. What am I doing wrong? (ps for the demo I copied the original checkbox formatter. and btw by using formatter:'checkbox' the thing works just right...but I need a custom one)

here is my full demo code

http://savdoc.sav.fi/democode.txt

05/09/2012
09:27
Avatar
jari.haikonen
New Member
Members
Forum Posts: 2
Member Since:
05/09/2012
sp_UserOfflineSmall Offline

Got it all working (with my version of the checkbox) with this

<script>

function mychkclick(rowid, colid) {

val = $("#list4").getCell(rowid, colid);

newValue = "1";

if (val == "1") newValue = "2";

$("#list4").setCell(rowid, colid, newValue);

val = $("#list4").getCell(rowid, colid);

}

jQuery.extend($.fn.fmatter , {

mycheckbox : function(cellvalue, options, rowobject) {

var checked = cellvalue == '2' ? "checked='checked' " : "";

var disabled = cellvalue == '0' ? "disabled='disabled' " : "";

rtn = "<input type='checkbox' onclick="mychkclick('" + options.rowId + "','" + options.colModel.name + "');" " + checked + disabled + "value='"+ cellvalue+ "' />";

return rtn;

}

});

jQuery.extend($.fn.fmatter.mycheckbox , {

unformat : function(cellvalue, options, cellobject) {

var checked = $(cellobject).html().indexOf("checked",0) != -1 ? "2" : "1";

return checked;

}

});

var mydata = [

{id:"1",name:"test",checkbox:1},

{id:"2",name:"test2",checkbox:0},

];

jQuery("#list4").jqGrid({

datatype: "local",

data: mydata,

height: 250,

colNames:['id','name','checkbox'],

colModel:[

{name:'id',index:'id', width:60, sorttype:"int"},

{name:'name',index:'name', width:100},

{name:'checkbox',index:'checkbox', width:80, align:"right",sorttype:"float",editable:true,edittype:'select',formatter:'mycheckbox',formatoptions:{disabled:false}, },

],

multiselect: true,

caption: "Demo"

});

</script>

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
42 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information