GroupingStore-min.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.data.GroupingStore = Ext.extend(Ext.data.Store, {
  7. remoteGroup : false,
  8. groupOnSort : false,
  9. clearGrouping : function() {
  10. this.groupField = false;
  11. if (this.remoteGroup) {
  12. if (this.baseParams) {
  13. delete this.baseParams.groupBy
  14. }
  15. this.reload()
  16. } else {
  17. this.applySort();
  18. this.fireEvent("datachanged", this)
  19. }
  20. },
  21. groupBy : function(C, B) {
  22. if (this.groupField == C && !B) {
  23. return
  24. }
  25. this.groupField = C;
  26. if (this.remoteGroup) {
  27. if (!this.baseParams) {
  28. this.baseParams = {}
  29. }
  30. this.baseParams["groupBy"] = C
  31. }
  32. if (this.groupOnSort) {
  33. this.sort(C);
  34. return
  35. }
  36. if (this.remoteGroup) {
  37. this.reload()
  38. } else {
  39. var A = this.sortInfo || {};
  40. if (A.field != C) {
  41. this.applySort()
  42. } else {
  43. this.sortData(C)
  44. }
  45. this.fireEvent("datachanged", this)
  46. }
  47. },
  48. applySort : function() {
  49. Ext.data.GroupingStore.superclass.applySort.call(this);
  50. if (!this.groupOnSort && !this.remoteGroup) {
  51. var A = this.getGroupState();
  52. if (A && A != this.sortInfo.field) {
  53. this.sortData(this.groupField)
  54. }
  55. }
  56. },
  57. applyGrouping : function(A) {
  58. if (this.groupField !== false) {
  59. this.groupBy(this.groupField, true);
  60. return true
  61. } else {
  62. if (A === true) {
  63. this.fireEvent("datachanged", this)
  64. }
  65. return false
  66. }
  67. },
  68. getGroupState : function() {
  69. return this.groupOnSort && this.groupField !== false
  70. ? (this.sortInfo ? this.sortInfo.field : undefined)
  71. : this.groupField
  72. }
  73. });