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_Related Related Topics sp_TopicIcon
set dynamic value to checkbox and access it value in java script
27/04/2011
16:30
Avatar
brijesh.mistry
Ahmedabad
Member
Members
Forum Posts: 3
Member Since:
27/04/2011
sp_UserOfflineSmall Offline

Hello all,

i pasting my code from html,problem is that all the checkbox is by default selected which should be unchecked,and how to access value of it from the javascript function.pls need a help

It is treegrid implementation.Thank is advance,

Code:

<script type="text/javascript">

$(function(){

var mydata = [ {id:"3",name:"Service Tax",value:"10.0",taxtype:"Package Amount",level:"0", parent:"0", isLeaf:false, expanded:false},

{id:"5",name:"Service Tax",value:"3.0",taxtype:"Package Amount",level:"1", parent:"3", isLeaf:false, expanded:false},

{id:"6",name:"Education Cess",value:"3.0",taxtype:"Package Amount",level:"2", parent:"5", isLeaf:true, expanded:false},

{id:"10",name:"Service Tax",value:"6.0",taxtype:"Grand Total Amount",level:"2", parent:"5", isLeaf:true, expanded:false},

{id:"11",name:"Service Tax",value:"6.0",taxtype:"Grand Total Amount",level:"1", parent:"3", isLeaf:true, expanded:false},

{id:"12",name:"Service Tax",value:"7.0",taxtype:"Grand Total Amount",level:"1", parent:"3", isLeaf:true, expanded:false},

{id:"13",name:"Service Tax",value:"7.0",taxtype:"Package Amount",level:"1", parent:"3", isLeaf:true, expanded:false},

{id:"4",name:"Education Cess",value:"4.0",taxtype:"Grand Total Amount",level:"0", parent:"0", isLeaf:false, expanded:false},

{id:"7",name:"Service Tax",value:"6.0",taxtype:"Grand Total Amount",level:"1", parent:"4", isLeaf:true, expanded:false},

{id:"8",name:"Service Tax",value:"6.0",taxtype:"Grand Total Amount",level:"1", parent:"4", isLeaf:true, expanded:false},

{id:"9",name:"Service Tax",value:"6.0",taxtype:"Grand Total Amount",level:"1", parent:"4", isLeaf:true, expanded:false},

{id:"1_2",name:"Sub Menu1",value:"1",taxtype:"Global one",level:"0", parent:"0", isLeaf:true, expanded:false}],

grid = $("#treegridsamp");

grid.jqGrid({

datatype: "local",

data: mydata,

colNames:['id','Name','Value','Tax type','Select'],

colModel:[

{name:'id',index:'id',width:100,hidden:true,sortable:false},

{name:'name',index:'name',width:'330',sortable:false},

{name:'value',index:'value',width:'300',sortable:false},

{name:'taxtype',index:'taxtype',width:'450',sortable:false},

{name:'id', align:'center', editable:true,sortable:false, edittype:'checkbox',editoptions: {checked:""}, formatter: 'checkbox', formatoptions:{disabled : false}, width:'100'}

],

height:'100%',

width:'100%',

//pager : "#ptreegrid",

sortname:'id',

treeGrid:true,

treeGridModel:'adjacency',

treedatatype:"local",

ExpandColumn:'name',

hidegrid:false,

caption: "Configure default Tax Information",

gridComplete: function () { checkBox();}

});

grid["0"].addJSONData({

total: 1,

page: 1,

records: mydata.length,

rows: mydata

});

});

</script>

 <body>

<table id="treegridsamp"><tr><td/></tr></table>

<div id="dvtreegridsamp"/>

</body>

27/04/2011
18:23
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

You problem exist because you use for the chechbox column the same name 'id' as the name of the first column. If you chenged the name of the last column to any other namue, for example, name:'myCheckbox' the problem will be solved.

Best regards
Oleg 

28/04/2011
11:32
Avatar
brijesh.mistry
Ahmedabad
Member
Members
Forum Posts: 3
Member Since:
27/04/2011
sp_UserOfflineSmall Offline

Thanks for a quick reply,

i changed the code accordinging but still checkbox is selected by default which should be unselected,please reply me if there is still error in my code i am attching screen shot also.

$(function(){

var mydata = [ {id:"3",checkid:"3", name:"Service Tax",value:"10.0",taxtype:"Package Amount",level:"0", parent:"0", isLeaf:false, expanded:false},

{id:"5",checkid:"5", name:"Service Tax",value:"3.0",taxtype:"Package Amount",level:"1", parent:"3", isLeaf:false, expanded:false},

{id:"6",checkid:"6", name:"Education Cess",value:"3.0",taxtype:"Package Amount",level:"2", parent:"5", isLeaf:true, expanded:false},

{id:"10",checkid:"10", name:"Service Tax",value:"6.0",taxtype:"Grand Total Amount",level:"2", parent:"5", isLeaf:true, expanded:false},

{id:"11",checkid:"11", name:"Service Tax",value:"6.0",taxtype:"Grand Total Amount",level:"1", parent:"3", isLeaf:true, expanded:false},

{id:"12",checkid:"12", name:"Service Tax",value:"7.0",taxtype:"Grand Total Amount",level:"1", parent:"3", isLeaf:true, expanded:false},

{id:"13",checkid:"13", name:"Service Tax",value:"7.0",taxtype:"Package Amount",level:"1", parent:"3", isLeaf:true, expanded:false},

{id:"4",checkid:"4", name:"Education Cess",value:"4.0",taxtype:"Grand Total Amount",level:"0", parent:"0", isLeaf:false, expanded:false},

{id:"7",checkid:"7", name:"Service Tax",value:"6.0",taxtype:"Grand Total Amount",level:"1", parent:"4", isLeaf:true, expanded:false},

{id:"8",checkid:"8", name:"Service Tax",value:"6.0",taxtype:"Grand Total Amount",level:"1", parent:"4", isLeaf:true, expanded:false},

{id:"9",checkid:"9", name:"Service Tax",value:"6.0",taxtype:"Grand Total Amount",level:"1", parent:"4", isLeaf:true, expanded:false},

{id:"1_2",name:"Sub Menu1",value:"1",taxtype:"Global one",level:"0", parent:"0", isLeaf:true, expanded:false}],

grid = $("#treegridsamp");

grid.jqGrid({

datatype: "local",

data: mydata,

colNames:['id','Name','Value','Tax type','Select'],

colModel:[

{name:'id',index:'id',width:100,hidden:true,sortable:false},

{name:'name',index:'name',width:'330',sortable:false},

{name:'value',index:'value',width:'300',sortable:false},

{name:'taxtype',index:'taxtype',width:'450',sortable:false},

{name:'checkid', align:'center', editable:true, edittype:'checkbox',editoptions: {value: "Yes:No", defaultValue: "No"}, formatter: 'checkbox', formatoptions:{disabled : false}, width:'100'}

],

height:'100%',

width:'100%',

//pager : "#ptreegrid",

sortname:'id',

treeGrid:true,

treeGridModel:'adjacency',

treedatatype:"local",

ExpandColumn:'name',

hidegrid:false,

caption: "Configure default Tax Information",

gridComplete: function () { checkBox();}

});

grid["0"].addJSONData({

total: 1,

page: 1,

records: mydata.length,

rows: mydata

});

});

</script>

<TITLE>24online</TITLE>

</head>

OlegK said:

You problem exist because you use for the chechbox column the same name 'id' as the name of the first column. If you chenged the name of the last column to any other namue, for example, name:'myCheckbox' the problem will be solved.

Best regards
Oleg 


Image Enlarger

28/04/2011
13:47
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Sorry, but I can't follow you. If you need a checkbox column you should place as the values "0", "1", "yes", "no", "true" or "false". Instead of that you fill in mydata array the checkid property with values like "3", ,,, "13". Only the last value (for id:"1_2",name:"Sub Menu1") contain no value for the checkid property and will be displayed as uncheched checkbox.

So you should just fill the mydata array with the correct values. Moreover, you should better use grid[0] instead of grid["0"] and define loadonce:true instead of data: mydata because you will fill the grid with respect of grid[0].addJSONData.

Best regards
Oleg 

19/05/2011
09:43
Avatar
brijesh.mistry
Ahmedabad
Member
Members
Forum Posts: 3
Member Since:
27/04/2011
sp_UserOfflineSmall Offline

Thank you for a quick reply..

Yes buddy u r right , i changed my codding so now checkbox is only used for yes/no .then using javascript i  iterate all the rows and check whether checkbox is checked or not if it is checked than i get its id from hidden column,and it's working fine.Smile

Forum Timezone: Europe/Sofia

Most Users Ever Online: 496

Currently Online:
33 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