forked from extnet/Ext.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoreBase.cs
More file actions
2674 lines (2410 loc) · 98.7 KB
/
StoreBase.cs
File metadata and controls
2674 lines (2410 loc) · 98.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/********
* @version : 2.1.1 - Ext.NET Pro License
* @author : Ext.NET, Inc. http://www.ext.net/
* @date : 2012-12-10
* @copyright : Copyright (c) 2007-2012, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
* @license : See license.txt and http://www.ext.net/license/.
********/
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net.Utilities;
using System.Data;
namespace Ext.Net
{
/// <summary>
/// The Store class encapsulates a client side cache of Model objects. Stores load data via a Proxy, and also provide functions for sorting, filtering and querying the model instances contained within it.
///
/// Creating a Store is easy - we just tell it the Model and the Proxy to use to load and save its data:
///
/// // Set up a model to use in our Store
/// Ext.define('User', {
/// extend: 'Ext.data.Model',
/// fields: [
/// {name: 'firstName', type: 'string'},
/// {name: 'lastName', type: 'string'},
/// {name: 'age', type: 'int'},
/// {name: 'eyeColor', type: 'string'}
/// ]
/// });
///
/// var myStore = new Ext.data.Store({
/// model: 'User',
/// proxy: {
/// type: 'ajax',
/// url : '/users.json',
/// reader: {
/// type: 'json',
/// root: 'users'
/// }
/// },
/// autoLoad: true
/// });
/// In the example above we configured an AJAX proxy to load data from the url '/users.json'. We told our Proxy to use a JsonReader to parse the response from the server into Model object - see the docs on JsonReader for details.
///
/// Inline data
///
/// Stores can also load data inline. Internally, Store converts each of the objects we pass in as data into Model instances:
///
/// new Ext.data.Store({
/// model: 'User',
/// data : [
/// {firstName: 'Ed', lastName: 'Spencer'},
/// {firstName: 'Tommy', lastName: 'Maintz'},
/// {firstName: 'Aaron', lastName: 'Conran'},
/// {firstName: 'Jamie', lastName: 'Avins'}
/// ]
/// });
/// Loading inline data using the method above is great if the data is in the correct format already (e.g. it doesn't need to be processed by a reader). If your inline data requires processing to decode the data structure, use a MemoryProxy instead (see the MemoryProxy docs for an example).
///
/// Additional data can also be loaded locally using add.
///
/// Loading Nested Data
///
/// Applications often need to load sets of associated data - for example a CRM system might load a User and her Orders. Instead of issuing an AJAX request for the User and a series of additional AJAX requests for each Order, we can load a nested dataset and allow the Reader to automatically populate the associated models. Below is a brief example, see the Ext.data.reader.Reader intro docs for a full explanation:
///
/// var store = new Ext.data.Store({
/// autoLoad: true,
/// model: "User",
/// proxy: {
/// type: 'ajax',
/// url : 'users.json',
/// reader: {
/// type: 'json',
/// root: 'users'
/// }
/// }
/// });
/// Which would consume a response like this:
///
/// {
/// "users": [
/// {
/// "id": 1,
/// "name": "Ed",
/// "orders": [
/// {
/// "id": 10,
/// "total": 10.76,
/// "status": "invoiced"
/// },
/// {
/// "id": 11,
/// "total": 13.45,
/// "status": "shipped"
/// }
/// ]
/// }
/// ]
/// }
/// See the Ext.data.reader.Reader intro docs for a full explanation.
///
/// Filtering and Sorting
///
/// Stores can be sorted and filtered - in both cases either remotely or locally. The sorters and filters are held inside MixedCollection instances to make them easy to manage. Usually it is sufficient to either just specify sorters and filters in the Store configuration or call sort or filter:
///
/// var store = new Ext.data.Store({
/// model: 'User',
/// sorters: [
/// {
/// property : 'age',
/// direction: 'DESC'
/// },
/// {
/// property : 'firstName',
/// direction: 'ASC'
/// }
/// ],
///
/// filters: [
/// {
/// property: 'firstName',
/// value : /Ed/
/// }
/// ]
/// });
/// The new Store will keep the configured sorters and filters in the MixedCollection instances mentioned above. By default, sorting and filtering are both performed locally by the Store - see remoteSort and remoteFilter to allow the server to perform these operations instead.
///
/// Filtering and sorting after the Store has been instantiated is also easy. Calling filter adds another filter to the Store and automatically filters the dataset (calling filter with no arguments simply re-applies all existing filters). Note that by default sortOnFilter is set to true, which means that your sorters are automatically reapplied if using local sorting.
///
/// store.filter('eyeColor', 'Brown');
/// Change the sorting at any time by calling sort:
///
/// store.sort('height', 'ASC');
/// Note that all existing sorters will be removed in favor of the new sorter data (if sort is called with no arguments, the existing sorters are just reapplied instead of being removed). To keep existing sorters and add new ones, just add them to the MixedCollection:
///
/// store.sorters.add(new Ext.util.Sorter({
/// property : 'shoeSize',
/// direction: 'ASC'
/// }));
///
/// store.sort();
/// Registering with StoreManager
///
/// Any Store that is instantiated with a storeId will automatically be registed with the StoreManager. This makes it easy to reuse the same store in multiple views:
///
/// //this store can be used several times
/// new Ext.data.Store({
/// model: 'User',
/// storeId: 'usersStore'
/// });
///
/// new Ext.List({
/// store: 'usersStore',
///
/// //other config goes here
/// });
///
/// new Ext.view.View({
/// store: 'usersStore',
///
/// //other config goes here
/// });
/// Further Reading
///
/// Stores are backed up by an ecosystem of classes that enables their operation. To gain a full understanding of these pieces and how they fit together, see:
///
/// Proxy - overview of what Proxies are and how they are used
/// Model - the core class in the data package
/// Reader - used by any subclass of ServerProxy to read a response
/// </summary>
[Meta]
public abstract partial class StoreBase : AbstractStore
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
protected override void OnBeforeClientInit(Observable sender)
{
base.OnBeforeClientInit(sender);
if (!RequestManager.IsAjaxRequest || this.IsDynamic)
{
this.EnsureDataBound();
}
}
#region Base
/// <summary>
/// If true then submitted data will be decoded
/// </summary>
[Meta]
[Category("Config Options")]
[DefaultValue(false)]
[Description("If true then submitted data will be decoded")]
public virtual bool AutoDecode
{
get
{
return this.State.Get<bool>("AutoDecode", false);
}
set
{
this.State.Set("AutoDecode", value);
}
}
/// <summary>
/// Allows the Store to prefetch and cache in a page cache, pages of Records, and to then satisfy loading requirements from this page cache.
///
/// To use buffered Stores, initiate the process by loading the first page. The number of rows rendered are determined automatically, and the range of pages needed to keep the cache primed for scrolling is requested and cached. Example:
///
/// // Load page 1 myStore.loadPage(1);
///
/// A PagingScroller is instantiated which will monitor the scrolling in the grid, and refresh the view's rows from the page cache as needed. It will also pull new data into the page cache when scrolling of the view draws upon data near either end of the prefetched data.
///
/// The margins which trigger view refreshing from the prefetched data are Ext.grid.PagingScroller.numFromEdge, Ext.grid.PagingScroller.leadingBufferZone and Ext.grid.PagingScroller.trailingBufferZone.
///
/// The margins which trigger loading more data into the page cache are, leadingBufferZone and trailingBufferZone.
///
/// By defult, only 5 pages of data are cached in the page cache, with pages "scrolling" out of the buffer as the view moves down through the dataset. This can be increased by changing the purgePageSize value. Setting this value to zero means that no pages are ever scrolled out of the page cache, and that eventually the whole dataset may become present in the page cache. This is sometimes desirable as long as datasets do not reach astronomical proportions.
///
/// Selection state may be maintained across page boundaries by configuring the SelectionModel not to discard records from its collection when those Records cycle out of the Store's primary collection. This is done by configuring the SelectionModel like this:
///
/// selModel: {
/// pruneRemoved: false
/// }
///
/// Defaults to: false
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue(false)]
[NotifyParentProperty(true)]
[Description("Allow the store to buffer and pre-fetch pages of records. This is to be used in conjunction with a view will tell the store to pre-fetch records ahead of a time.")]
public virtual bool Buffered
{
get
{
return this.State.Get<bool>("Buffered", false);
}
set
{
this.State.Set("Buffered", value);
}
}
/// <summary>
/// True to empty the store when loading another page via loadPage, nextPage or previousPage (defaults to true). Setting to false keeps existing records, allowing large data sets to be loaded one page at a time but rendered all together. Defaults to: true
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue(true)]
[NotifyParentProperty(true)]
[Description("True to empty the store when loading another page via loadPage, nextPage or previousPage (defaults to true). Setting to false keeps existing records, allowing large data sets to be loaded one page at a time but rendered all together.")]
public virtual bool ClearOnPageLoad
{
get
{
return this.State.Get<bool>("ClearOnPageLoad", true);
}
set
{
this.State.Set("ClearOnPageLoad", value);
}
}
/// <summary>
/// True to clear anything in the removed record collection when the store loads.
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue(true)]
[NotifyParentProperty(true)]
[Description("True to clear anything in the removed record collection when the store loads.")]
public virtual bool ClearRemovedOnLoad
{
get
{
return this.State.Get<bool>("ClearRemovedOnLoad", true);
}
set
{
this.State.Set("ClearRemovedOnLoad", value);
}
}
private object data = null;
/// <summary>
/// Optional array of Model instances or data objects to load locally. See "Inline data" above for details.
/// </summary>
[Meta]
[DefaultValue(null)]
[NotifyParentProperty(true)]
[Description("Optional array of Model instances or data objects to load locally. See \"Inline data\" above for details.")]
public virtual object Data
{
get
{
return this.data;
}
set
{
this.data = value;
}
}
/// <summary>
///
/// </summary>
[ConfigOption("data", JsonMode.Raw)]
[DefaultValue(null)]
protected virtual string DataProxy
{
get
{
if (this.Data == null)
{
return null;
}
return JSON.Serialize(this.Data);
}
}
/// <summary>
/// The direction in which sorting should be applied when grouping. Defaults to "ASC" - the other supported value is "DESC"
/// </summary>
[Meta]
[ConfigOption(JsonMode.ToLower)]
[DefaultValue(SortDirection.Default)]
[Description("The direction in which sorting should be applied when grouping. Defaults to \"ASC\" - the other supported value is \"DESC\"")]
public virtual SortDirection GroupDir
{
get
{
return this.State.Get<SortDirection>("GroupDir", SortDirection.Default);
}
set
{
this.State.Set("GroupDir", value);
}
}
/// <summary>
/// The (optional) field by which to group data in the store. Internally, grouping is very similar to sorting - the groupField and groupDir are injected as the first sorter (see sort). Stores support a single level of grouping, and groups can be fetched via the getGroups method.
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue("")]
[Description("The (optional) field by which to group data in the store. Internally, grouping is very similar to sorting - the groupField and groupDir are injected as the first sorter (see sort). Stores support a single level of grouping, and groups can be fetched via the getGroups method.")]
public virtual string GroupField
{
get
{
return this.State.Get<string>("GroupField", "");
}
set
{
this.State.Set("GroupField", value);
}
}
private DataSorterCollection groupers;
/// <summary>
/// The collection of groupers currently applied to this Store
/// </summary>
[Meta]
[ConfigOption(JsonMode.Array)]
[NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Description("The collection of groupers currently applied to this Store")]
public virtual DataSorterCollection Groupers
{
get
{
return this.groupers ?? (this.groupers = new DataSorterCollection());
}
}
/// <summary>
/// When buffered, the number of extra rows to keep cached on the leading side of scrolling buffer as scrolling proceeds. A larger number means fewer replenishments from the server. Defaults to: 200
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue(200)]
[NotifyParentProperty(true)]
[Description("When buffered, the number of extra rows to keep cached on the leading side of scrolling buffer as scrolling proceeds. A larger number means fewer replenishments from the server. Defaults to: 200")]
public virtual int LeadingBufferZone
{
get
{
return this.State.Get<int>("LeadingBufferZone", 200);
}
set
{
this.State.Set("LeadingBufferZone", value);
}
}
/// <summary>
/// The number of records considered to form a 'page'. This is used to power the built-in paging using the nextPage and previousPage functions when the grid is paged using a PagingScroller Defaults to 25.
///
/// If this Store is buffered, pages are loaded into a page cache before the Store's data is updated from the cache. The pageSize is the number of rows loaded into the cache in one request. This will not affect the rendering of a buffered grid, but a larger page size will mean fewer loads.
///
/// In a buffered grid, scrolling is monitored, and the page cache is kept primed with data ahead of the direction of scroll to provide rapid access to data when scrolling causes it to be required. Several pages in advance may be requested depending on various parameters.
///
/// It is recommended to tune the pageSize, trailingBufferZone and leadingBufferZone configurations based upon the conditions pertaining in your deployed application.
///
/// The provided SDK example examples/grid/infinite-scroll-grid-tuner.html can be used to experiment with different settings including simulating Ajax latency.
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue(25)]
[NotifyParentProperty(true)]
[Description("The number of records considered to form a 'page'. This is used to power the built-in paging using the nextPage and previousPage functions. Defaults to 25.")]
public virtual int PageSize
{
get
{
return this.State.Get<int>("PageSize", 25);
}
set
{
this.State.Set("PageSize", value);
}
}
/// <summary>
/// Valid only when used with a buffered Store.
///
/// The number of pages additional to the required buffered range to keep in the prefetch cache before purging least recently used records.
///
/// For example, if the height of the view area and the configured trailingBufferZone and leadingBufferZone require that there are three pages in the cache, then a purgePageCount of 5 ensures that up to 8 pages can be in the page cache any any one time.
///
/// A value of 0 indicates to never purge the prefetched data.
///
/// Defaults to: 5
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue(5)]
[NotifyParentProperty(true)]
[Description("The number of pages to keep in the cache before purging additional records. A value of 0 indicates to never purge the prefetched data. This option is only relevant when the buffered option is set to true.")]
public virtual int PurgePageCount
{
get
{
return this.State.Get<int>("PurgePageCount", 5);
}
set
{
this.State.Set("PurgePageCount", value);
}
}
/// <summary>
/// True to defer any filtering operation to the server. If false, filtering is done locally on the client. Defaults to false.
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue(false)]
[NotifyParentProperty(true)]
[Description("True to defer any filtering operation to the server. If false, filtering is done locally on the client. Defaults to false.")]
public virtual bool RemoteFilter
{
get
{
return this.State.Get<bool>("RemoteFilter", false);
}
set
{
this.State.Set("RemoteFilter", value);
}
}
/// <summary>
/// True if the grouping should apply on the server side, false if it is local only (defaults to false). If the grouping is local, it can be applied immediately to the data. If it is remote, then it will simply act as a helper, automatically sending the grouping information to the server.
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue(false)]
[NotifyParentProperty(true)]
[Description("True if the grouping should apply on the server side, false if it is local only (defaults to false). If the grouping is local, it can be applied immediately to the data. If it is remote, then it will simply act as a helper, automatically sending the grouping information to the server.")]
public virtual bool RemoteGroup
{
get
{
return this.State.Get<bool>("RemoteGroup", false);
}
set
{
this.State.Set("RemoteGroup", value);
}
}
/// <summary>
/// True to defer any sorting operation to the server. If false, sorting is done locally on the client. Defaults to false.
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue(false)]
[NotifyParentProperty(true)]
[Description("True to defer any sorting operation to the server. If false, sorting is done locally on the client. Defaults to false.")]
public virtual bool RemoteSort
{
get
{
return this.State.Get<bool>("RemoteSort", false);
}
set
{
this.State.Set("RemoteSort", value);
}
}
/// <summary>
/// True to perform remote paging
/// </summary>
[Meta]
[DefaultValue(true)]
[Description("True to perform remote paging.")]
public virtual bool RemotePaging
{
get
{
return this.State.Get<bool>("RemotePaging", true);
}
set
{
this.State.Set("RemotePaging", value);
}
}
/// <summary>
/// True to use PagingStore instance
/// </summary>
[Meta]
[DefaultValue(false)]
[Description("True to use PagingStore instance")]
public virtual bool IsPagingStore
{
get
{
return this.State.Get<bool>("IsPagingStore", false);
}
set
{
this.State.Set("IsPagingStore", value);
}
}
/// <summary>
/// For local filtering only, causes sort to be called whenever filter is called, causing the sorters to be reapplied after filtering. Defaults to true
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue(true)]
[NotifyParentProperty(true)]
[Description("For local filtering only, causes sort to be called whenever filter is called, causing the sorters to be reapplied after filtering. Defaults to true")]
public virtual bool SortOnFilter
{
get
{
return this.State.Get<bool>("SortOnFilter", true);
}
set
{
this.State.Set("SortOnFilter", value);
}
}
/// <summary>
/// When buffered, the number of extra records to keep cached on the trailing side of scrolling buffer as scrolling proceeds. A larger number means fewer replenishments from the server. Defaults to: 25
/// </summary>
[Meta]
[ConfigOption]
[DefaultValue(25)]
[NotifyParentProperty(true)]
[Description("When buffered, the number of extra records to keep cached on the trailing side of scrolling buffer as scrolling proceeds. A larger number means fewer replenishments from the server. Defaults to: 25")]
public virtual int TrailingBufferZone
{
get
{
return this.State.Get<int>("TrailingBufferZone", 25);
}
set
{
this.State.Set("TrailingBufferZone", value);
}
}
/// <summary>
/// If true show a warning before load/reload if store has dirty data
/// </summary>
[Meta]
[ConfigOption]
[Category("3. Store")]
[DefaultValue(false)]
[Description("If true show a warning before load/reload if store has dirty data")]
public virtual bool WarningOnDirty
{
get
{
return this.State.Get<bool>("WarningOnDirty", false);
}
set
{
this.State.Set("WarningOnDirty", value);
}
}
/// <summary>
/// The title of window showing before load if the dirty data exists
/// </summary>
[Meta]
[ConfigOption]
[Localizable(true)]
[Category("3. Store")]
[DefaultValue("Uncommitted Changes")]
[Description("The title of window showing before load if the dirty data exists")]
public virtual string DirtyWarningTitle
{
get
{
return this.State.Get<string>("DirtyWarningTitle", "Uncommitted Changes");
}
set
{
this.State.Set("DirtyWarningTitle", value);
}
}
/// <summary>
/// The text of window showing before load if the dirty data exists
/// </summary>
[Meta]
[ConfigOption]
[Category("3. Store")]
[DefaultValue("You have uncommitted changes. Are you sure you want to load/reload data?")]
[Description("The text of window showing before load if the dirty data exists")]
public virtual string DirtyWarningText
{
get
{
return this.State.Get<string>("DirtyWarningText", "You have uncommitted changes. Are you sure you want to load/reload data?");
}
set
{
this.State.Set("DirtyWarningText", value);
}
}
/// <summary>
/// If true then only properties included to reader will be converted to json
/// </summary>
[Meta]
[Category("3. Store")]
[DefaultValue(true)]
[Description("If true then only properties included to reader will be converted to json")]
public virtual bool IgnoreExtraFields
{
get
{
return this.State.Get<bool>("IgnoreExtraFields", true);
}
set
{
this.State.Set("IgnoreExtraFields", value);
}
}
private ReaderCollection reader;
/// <summary>
/// The Ext.data.reader.Reader to use to decode the server's response. This can either be a Reader instance, a config object or just a valid Reader type name (e.g. 'json', 'xml').
/// </summary>
[Meta]
[NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Description("The Ext.data.reader.Reader to use to decode the server's response. This can either be a Reader instance, a config object or just a valid Reader type name (e.g. 'json', 'xml').")]
public virtual ReaderCollection Reader
{
get
{
return this.reader ?? (this.reader = new ReaderCollection());
}
}
private WriterCollection writer;
/// <summary>
/// The Ext.data.writer.Writer to use to encode any request sent to the server. This can either be a Writer instance, a config object or just a valid Writer type name (e.g. 'json', 'xml').
/// </summary>
[Meta]
[NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Description("The Ext.data.writer.Writer to use to encode any request sent to the server. This can either be a Writer instance, a config object or just a valid Writer type name (e.g. 'json', 'xml').")]
public virtual WriterCollection Writer
{
get
{
return this.writer ?? (this.writer = new WriterCollection());
}
}
/// <summary>
/// Adds Model instances to the Store by instantiating them based on a JavaScript object. When adding already- instantiated Models, use insert instead. The instances will be added at the end of the existing collection. This method accepts either a single argument array of Model instances or any number of model instance arguments.
/// </summary>
/// <param name="data">The data for each model</param>
[Meta]
public void Add(object data)
{
this.Call("add", data);
}
/// <summary>
/// Adds Model instances to the Store by instantiating them based on a JavaScript object. When adding already- instantiated Models, use insert instead. The instances will be added at the end of the existing collection. This method accepts either a single argument array of Model instances or any number of model instance arguments.
/// </summary>
/// <param name="data">The data for each model</param>
[Meta]
public void Add(System.Collections.IEnumerable data)
{
this.Call("add", data);
}
/// <summary>
/// Adds Model instances to the Store by instantiating them based on a JavaScript object. When adding already- instantiated Models, use insert instead. The instances will be added at the end of the existing collection. This method accepts either a single argument array of Model instances or any number of model instance arguments.
/// </summary>
/// <param name="data">The data for each model</param>
[Meta]
public void Add(ModelProxy model)
{
this.Call("add", JRawValue.From(model));
}
/// <summary>
/// (Local sort only) Inserts the passed Record into the Store at the index where it should go based on the current sort information.
/// </summary>
/// <param name="data"></param>
[Meta]
public void AddSorted(ModelProxy model)
{
this.Call("addSorted", JRawValue.From(model));
}
/// <summary>
/// Revert to a view of the Record cache with no filtering applied.
/// </summary>
[Meta]
public virtual void ClearFilter()
{
this.ClearFilter(false);
}
/// <summary>
/// Revert to a view of the Record cache with no filtering applied.
/// </summary>
/// <param name="suppressEvent">If true the filter is cleared silently without firing the datachanged event.</param>
[Meta]
public virtual void ClearFilter(bool suppressEvent)
{
this.Call("clearFilter", suppressEvent);
}
/// <summary>
/// Clear any groupers in the store
/// </summary>
[Meta]
public virtual void ClearGrouping()
{
RequestManager.EnsureDirectEvent();
this.Call("clearGrouping");
}
/// <summary>
/// Commits all Records with outstanding changes. To handle updates for changes, subscribe to the Store's update event, and perform updating when the third parameter is Ext.data.Record.COMMIT.
/// </summary>
[Meta]
public virtual void CommitChanges()
{
RequestManager.EnsureDirectEvent();
this.Call("commitChanges");
}
/// <summary>
/// Calls the specified function for each of the Records in the cache. When store is filtered, only loops over the filtered records.
/// </summary>
/// <param name="fn">The function to call. The Record is passed as the first parameter. Returning false aborts and exits the iteration.</param>
/// <param name="scope">(optional) The scope (this reference) in which the function is executed. Defaults to the current Record in the iteration.</param>
[Meta]
public virtual void Each(JFunction fn, string scope)
{
this.Call("each", new JRawValue(fn.ToScript()), new JRawValue(scope));
}
/// <summary>
/// Calls the specified function for each of the Records in the cache.
/// </summary>
/// <param name="fn">The function to call. The Record is passed as the first parameter. Returning false aborts and exits the iteration.</param>
[Meta]
public virtual void Each(JFunction fn)
{
this.Call("each", new JRawValue(fn.ToScript()));
}
/// <summary>
/// Filters the loaded set of records by a given set of filters.
/// </summary>
/// <param name="field">A field on your records</param>
/// <param name="value">Either a string that the field should begin with, or a RegExp (should be raw token) to test against the field.</param>
[Meta]
public virtual void Filter(string field, string value)
{
if (TokenUtils.IsRawToken(value))
{
value = TokenUtils.ReplaceRawToken(value);
}
this.Call("filter", field, value);
}
/// <summary>
/// Filters the loaded set of records by a given set of filters.
/// </summary>
/// <param name="filters">The set of filters to apply to the data. These are stored internally on the store, but the filtering itself is done on the Store's MixedCollection.</param>
[Meta]
public virtual void Filter(DataFilterCollection filters)
{
this.Call("filter", new JRawValue(filters.Serialize()));
}
/// <summary>
/// Filters by a function. The specified function will be called for each Record in this Store. If the function returns true the Record is included, otherwise it is filtered out.
/// When store is filtered, most of the methods for accessing store data will be working only within the set of filtered records. Two notable exceptions are queryBy and getById.
/// </summary>
/// <param name="fn">The function to be called. It will be passed the following parameters: record, id</param>
[Meta]
public virtual void FilterBy(JFunction fn)
{
this.Call("filterBy", new JRawValue(fn.ToScript()));
}
/// <summary>
/// Filters by a function. The specified function will be called for each Record in this Store. If the function returns true the Record is included, otherwise it is filtered out.
/// When store is filtered, most of the methods for accessing store data will be working only within the set of filtered records. Two notable exceptions are queryBy and getById.
/// </summary>
/// <param name="fn">The function to be called. It will be passed the following parameters: record, id</param>
/// <param name="scope">The scope of the function (defaults to this)</param>
[Meta]
public virtual void FilterBy(JFunction fn, string scope)
{
this.Call("filterBy", new JRawValue(fn.ToScript()), new JRawValue(scope));
}
/// <summary>
/// Group data in the store
/// </summary>
/// <param name="field">A field on your records</param>
/// <param name="direction">The overall direction to group the data by. Defaults to "ASC".</param>
[Meta]
public virtual void Group(string field, SortDirection direction)
{
this.Call("group", field, direction.ToString().ToLowerInvariant());
}
/// <summary>
/// Group data in the store
/// </summary>
/// <param name="field">A field on your records</param>
[Meta]
public virtual void Group(string field)
{
this.Call("group", field);
}
/// <summary>
/// Group data in the store
/// </summary>
/// <param name="groupers">An Array of grouper configurations.</param>
[Meta]
public virtual void Group(DataSorterCollection groupers)
{
this.Call("group", new JRawValue(groupers.Serialize()));
}
/// <summary>
/// Group data in the store
/// </summary>
/// <param name="groupers">An Array of grouper configurations.</param>
/// <param name="direction">The overall direction to group the data by. Defaults to "ASC".</param>
[Meta]
public virtual void Group(DataSorterCollection groupers, SortDirection direction)
{
this.Call("group", new JRawValue(groupers.Serialize()), direction.ToString().ToLowerInvariant());
}
/// <summary>
/// Guarantee a specific range, this will load the store with a range (that must be the pageSize or smaller) and take care of any loading that may be necessary.
/// </summary>
/// <param name="start"></param>
/// <param name="end"></param>
[Meta]
public virtual void GuaranteeRange(int start, int end)
{
this.Call("guaranteeRange", start, end);
}
/// <summary>
/// Guarantee a specific range, this will load the store with a range (that must be the pageSize or smaller) and take care of any loading that may be necessary.
/// </summary>
/// <param name="start"></param>
/// <param name="end"></param>
[Meta]
public virtual void GuaranteeRange(int start, int end, JFunction callback)
{
this.Call("guaranteeRange", start, end, JRawValue.From(callback.ToScript()));
}
/// <summary>
/// Inserts Model instances into the Store at the given index and fires the add event. See also add.
/// </summary>
/// <param name="index">The start index at which to insert the passed Records.</param>
/// <param name="data">The data for each model</param>
[Meta]
public virtual void Insert(int index, object data)
{
this.Call("insert", index, data);
}
/// <summary>
/// Inserts Model instances into the Store at the given index and fires the add event. See also add.
/// </summary>
/// <param name="index">The start index at which to insert the passed Records.</param>
/// <param name="data">The data for each model</param>
[Meta]
public virtual void Insert(int index, System.Collections.IEnumerable data)
{
this.Call("insert", index, data);
}
/// <summary>
/// Loads an array of data straight into the Store.
/// Using this method is great if the data is in the correct format already (e.g. it doesn't need to be processed by a reader). If your data requires processing to decode the data structure, use a MemoryProxy instead.
/// </summary>
/// <param name="data">Array of data to load. Any non-model instances will be cast into model instances first</param>
/// <param name="append">True to add the records to the existing records in the store, false to remove the old ones first</param>
[Meta]
public virtual void LoadData(object data, bool append)
{
this.Call("loadData", data, append);
}
/// <summary>
/// Loads an array of data straight into the Store.
/// Using this method is great if the data is in the correct format already (e.g. it doesn't need to be processed by a reader). If your data requires processing to decode the data structure, use a MemoryProxy instead.
/// </summary>
/// <param name="data">Array of data to load. Any non-model instances will be cast into model instances first</param>
[Meta]
public virtual void LoadData(object data)
{
this.Call("loadData", data);
}
/// <summary>
/// Loads an array of data straight into the Store.
/// Using this method is great if the data is in the correct format already (e.g. it doesn't need to be processed by a reader). If your data requires processing to decode the data structure, use a MemoryProxy instead.
/// </summary>
/// <param name="data">Array of data to load. Any non-model instances will be cast into model instances first</param>
[Meta]
public virtual void LoadData(ModelProxy data)
{
this.Call("loadData", JRawValue.From(data.ModelInstance));
}
/// <summary>
/// Loads an array of data straight into the Store.
/// Using this method is great if the data is in the correct format already (e.g. it doesn't need to be processed by a reader). If your data requires processing to decode the data structure, use a MemoryProxy instead.
/// </summary>
/// <param name="data">Array of data to load. Any non-model instances will be cast into model instances first</param>
/// <param name="append">True to add the records to the existing records in the store, false to remove the old ones first</param>
[Meta]
public virtual void LoadData(ModelProxy data, bool append)
{
this.Call("loadData", JRawValue.From(data.ModelInstance), append);
}
/// <summary>
/// Loads a given 'page' of data by setting the start and limit values appropriately. Internally this just causes a normal load operation, passing in calculated 'start' and 'limit' params