cc0c4cda98f07fd91c1613559654973815562a3e.svn-base 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. Ext.grid.CheckboxSelectionModel = Ext.extend(Ext.grid.RowSelectionModel, {
  7. header : "<div class=\"x-grid3-hd-checker\">&#160;</div>",
  8. width : 20,
  9. sortable : false,
  10. fixed : true,
  11. dataIndex : "",
  12. id : "checker",
  13. initEvents : function() {
  14. Ext.grid.CheckboxSelectionModel.superclass.initEvents
  15. .call(this);
  16. this.grid.on("render", function() {
  17. var A = this.grid.getView();
  18. A.mainBody.on("mousedown", this.onMouseDown, this);
  19. Ext.fly(A.innerHd).on("mousedown",
  20. this.onHdMouseDown, this)
  21. }, this)
  22. },
  23. onMouseDown : function(C, B) {
  24. if (B.className == "x-grid3-row-checker") {
  25. C.stopEvent();
  26. var D = C.getTarget(".x-grid3-row");
  27. if (D) {
  28. var A = D.rowIndex;
  29. if (this.isSelected(A)) {
  30. this.deselectRow(A)
  31. } else {
  32. this.selectRow(A, true)
  33. }
  34. }
  35. }
  36. },
  37. onHdMouseDown : function(C, A) {
  38. if (A.className == "x-grid3-hd-checker") {
  39. C.stopEvent();
  40. var B = Ext.fly(A.parentNode);
  41. var D = B.hasClass("x-grid3-hd-checker-on");
  42. if (D) {
  43. B.removeClass("x-grid3-hd-checker-on");
  44. this.clearSelections()
  45. } else {
  46. B.addClass("x-grid3-hd-checker-on");
  47. this.selectAll()
  48. }
  49. }
  50. },
  51. renderer : function(B, C, A) {
  52. return "<div class=\"x-grid3-row-checker\">&#160;</div>"
  53. }
  54. });