Forum
Topic RSS
16:58
19/10/2010
OfflineI wanted to sort the column having checkbox formatter
I am using checkbox formatter with formatoptions:{disabled :false}
Suppose my grid contain 6 row with three row containing checkbox as checked and other as not checked
If user check fourth checkbox and then sort thean all four rows out of six should be at the start or end of grid
currently if user click on sort then only3 rows with checkbox as checked are displayed
I am using unformat option but the unformat function is not getting called while sorting
I am using jqgrid 7.2 version
Below is the code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> jq_grid test </title>
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.8.4.custom.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="js/src/css/ui.jqgrid.css"/>
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/src/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/src/grid.base.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="grid.headingColspan.js" type="text/javascript"></script>
<script type="text/javascript">
function myunformatCurrency (cellvalue, options, cellobject )
{
alert(cellvalue);
return cellvalue;
}
jQuery(document).ready(function(){
jQuery("#list").jqGrid({
datatype: "local",
height: 250,
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes', 'closed'],
colModel:[
{name:'id',index:'id', width:60, sorttype:"int"},
{name:'invdate',index:'invdate', width:90, sorttype:"date"},
{name:'name',index:'name', width:100},
{name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
{name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},
{name:'total',index:'total', width:80,align:"right",sorttype:"float"},
{name:'note',index:'note', width:150, sortable:false},
{name:'closed',index:'closed',width:55,align:'center', editable :true, formatter:'checkbox',formatoptions:{disabled :false}, unformat:myunformatCurrency,sortable: true,sorttype:"number" }
],
caption: "Manipulating Array Data"
});
var colNames = ["id", "invdate", "name", "note", "amount", "tax", "total", "closed"];
var newData = [
[10, "2007-09-01", "test4","new data", "600.00", "1.00", "601.00", 0],
[11, "2007-09-02", "test5","new data11", "602.00", "1.00", "603.00", 1],
[12, "2007-09-02", "test5","new data11", "602.00", "1.00", "603.00", 0],
[13, "2007-09-02", "test5","new data11", "602.00", "1.00", "603.00", 1],
[14, "2007-09-02", "test5","new data11", "602.00", "1.00", "603.00",0],
[15, "2007-09-02", "test5","new data11", "602.00", "1.00", "603.00", 1]
];
for(r = 0; r < newData.length; r++)
{
for(c = 0; c <= colNames.length; c++)
{
oper = c == 0 ? 'addRowData' : 'setRowData';
jQuery("#list").jqGrid(oper,r ,eval("({" + colNames[c]+":"" + newData[r][c] + ""})"));
}
}
});
</script>
</head>
<body>
<table id="list" class="scroll"></table>
<div id="pager" class="scroll" style="text-align:center;"></div>
</body>
</html>
Please help
Thanks,
Viral Gala
20:34
Moderators
30/10/2007
OfflineHello,
Let's think what is happen.
Q.What is formatter?
A. Formatter represets the data in new way into the grid and nothing more. They do not change the grid internal data or exactly if its visible data is changed under some condition it will not reflect the futute data processing.
Note that by defaule the disabled feature for the checkbox is true. The interaction is disbled exctley beqouse of the reasons above.
In order to work this you should implement some editing module like cell edit one.
Note that if you do that for local data manipulation you should set explecit which column is a id. For this purpose use key : true property - see docs.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 994
Currently Online:
14 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66
Log In
Home