datagrid 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb6758027fb0dcc66c2d3a285466b5aed3d4c3f1
4
- data.tar.gz: ea86794219dd8af94986c010c976809580680b55
3
+ metadata.gz: e883f173edbcd8f8a7791d5bfa043beb51b31b7c
4
+ data.tar.gz: 5a5287b4320935f8537fcc32b49c4666fd735770
5
5
  SHA512:
6
- metadata.gz: f91876b2190e994ff3259106a296034ff000ea1f3da233af811491d0c881e7a0bb14519b4a419f048b0865d4a9bc02c275a95ea10b648e2184d36f8d0cd4c50c
7
- data.tar.gz: a337280ece74f2b3e4b97e2749dde0d6a422405d71b051871222b0c5e2622bc8437e0bbbf40cff5cac04441b456c8640fcda82deb4f0a3399451ae16bb25dd94
6
+ metadata.gz: 5558c20d49ea5b4dcaf3071a861f2eeb86f72e968331d8c1fedd7bf028f857bfe6b1402aaf89fa2e697c1d65d33559cedcc3ee91daf586a0d55d321d2b2a2445
7
+ data.tar.gz: a7e98810429dfdd395f051bc783c27eb89673fcf45742a8107d47a020b68b51047e9dda4636526b49d8205d8147be24f476fc96e732e17a95d0845e2e6dbe6ce
data/Gemfile CHANGED
@@ -18,10 +18,10 @@ group :development do
18
18
  gem "sequel"
19
19
 
20
20
  group :mongo do
21
- gem "mongoid", "3.1.6"
22
- gem "mongo_mapper", "~> 0.11.0"
23
- gem "bson", "1.4.0"
24
- gem "bson_ext", "1.4.0"
21
+ gem "mongoid", "3.1.7"
22
+ gem "mongo_mapper", "~> 0.13.0"
23
+ gem "bson"
24
+ gem "bson_ext"
25
25
  end
26
26
 
27
27
  end
@@ -180,6 +180,10 @@ All advanced frontend things are described in:
180
180
 
181
181
  [Frontend section on wiki](https://github.com/bogdan/datagrid/wiki/Frontend)
182
182
 
183
+ ## Questions & Issues
184
+
185
+ If you have a question of any kind, just make an issue and describe your problem in details.
186
+
183
187
  ## Self-Promotion
184
188
 
185
189
  Like datagrid?
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.0
1
+ 1.4.1
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: datagrid 1.4.0 ruby lib
5
+ # stub: datagrid 1.4.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "datagrid"
9
- s.version = "1.4.0"
9
+ s.version = "1.4.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Bogdan Gusiev"]
14
- s.date = "2015-11-05"
14
+ s.date = "2016-02-10"
15
15
  s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters"
16
16
  s.email = "agresso@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -85,6 +85,7 @@ Gem::Specification.new do |s|
85
85
  "spec/datagrid/drivers/mongo_mapper_spec.rb",
86
86
  "spec/datagrid/drivers/mongoid_spec.rb",
87
87
  "spec/datagrid/drivers/sequel_spec.rb",
88
+ "spec/datagrid/filters/base_filter_spec.rb",
88
89
  "spec/datagrid/filters/boolean_enum_filter_spec.rb",
89
90
  "spec/datagrid/filters/composite_filters_spec.rb",
90
91
  "spec/datagrid/filters/date_filter_spec.rb",
@@ -127,7 +128,7 @@ Gem::Specification.new do |s|
127
128
  ]
128
129
  s.homepage = "http://github.com/bogdan/datagrid"
129
130
  s.licenses = ["MIT"]
130
- s.rubygems_version = "2.4.5"
131
+ s.rubygems_version = "2.4.8"
131
132
  s.summary = "Ruby gem to create datagrids"
132
133
 
133
134
  if s.respond_to? :specification_version then
@@ -143,10 +144,10 @@ Gem::Specification.new do |s|
143
144
  s.add_development_dependency(%q<nokogiri>, [">= 0"])
144
145
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
145
146
  s.add_development_dependency(%q<sequel>, [">= 0"])
146
- s.add_development_dependency(%q<mongoid>, ["= 3.1.6"])
147
- s.add_development_dependency(%q<mongo_mapper>, ["~> 0.11.0"])
148
- s.add_development_dependency(%q<bson>, ["= 1.4.0"])
149
- s.add_development_dependency(%q<bson_ext>, ["= 1.4.0"])
147
+ s.add_development_dependency(%q<mongoid>, ["= 3.1.7"])
148
+ s.add_development_dependency(%q<mongo_mapper>, ["~> 0.13.0"])
149
+ s.add_development_dependency(%q<bson>, [">= 0"])
150
+ s.add_development_dependency(%q<bson_ext>, [">= 0"])
150
151
  else
151
152
  s.add_dependency(%q<rails>, [">= 3.2.18"])
152
153
  s.add_dependency(%q<bundler>, [">= 0"])
@@ -157,10 +158,10 @@ Gem::Specification.new do |s|
157
158
  s.add_dependency(%q<nokogiri>, [">= 0"])
158
159
  s.add_dependency(%q<sqlite3>, [">= 0"])
159
160
  s.add_dependency(%q<sequel>, [">= 0"])
160
- s.add_dependency(%q<mongoid>, ["= 3.1.6"])
161
- s.add_dependency(%q<mongo_mapper>, ["~> 0.11.0"])
162
- s.add_dependency(%q<bson>, ["= 1.4.0"])
163
- s.add_dependency(%q<bson_ext>, ["= 1.4.0"])
161
+ s.add_dependency(%q<mongoid>, ["= 3.1.7"])
162
+ s.add_dependency(%q<mongo_mapper>, ["~> 0.13.0"])
163
+ s.add_dependency(%q<bson>, [">= 0"])
164
+ s.add_dependency(%q<bson_ext>, [">= 0"])
164
165
  end
165
166
  else
166
167
  s.add_dependency(%q<rails>, [">= 3.2.18"])
@@ -172,10 +173,10 @@ Gem::Specification.new do |s|
172
173
  s.add_dependency(%q<nokogiri>, [">= 0"])
173
174
  s.add_dependency(%q<sqlite3>, [">= 0"])
174
175
  s.add_dependency(%q<sequel>, [">= 0"])
175
- s.add_dependency(%q<mongoid>, ["= 3.1.6"])
176
- s.add_dependency(%q<mongo_mapper>, ["~> 0.11.0"])
177
- s.add_dependency(%q<bson>, ["= 1.4.0"])
178
- s.add_dependency(%q<bson_ext>, ["= 1.4.0"])
176
+ s.add_dependency(%q<mongoid>, ["= 3.1.7"])
177
+ s.add_dependency(%q<mongo_mapper>, ["~> 0.13.0"])
178
+ s.add_dependency(%q<bson>, [">= 0"])
179
+ s.add_dependency(%q<bson_ext>, [">= 0"])
179
180
  end
180
181
  end
181
182
 
@@ -48,7 +48,11 @@ module Datagrid
48
48
  end
49
49
 
50
50
  def desc(scope, order)
51
- scope.reorder(order).reverse_order
51
+ if order.respond_to?(:desc)
52
+ scope.reorder(order.desc)
53
+ else
54
+ scope.reorder(order).reverse_order
55
+ end
52
56
  end
53
57
 
54
58
  def reverse_order(scope)
@@ -102,6 +106,9 @@ module Datagrid
102
106
  end
103
107
 
104
108
  def batch_each(scope, batch_size, &block)
109
+ if scope.limit_value
110
+ raise Datagrid::ConfigurationError, "ActiveRecord can not use batches in combination with SQL limit"
111
+ end
105
112
  scope.find_each(batch_size ? { :batch_size => batch_size} : {}, &block)
106
113
  end
107
114
 
@@ -115,7 +115,7 @@ module Datagrid
115
115
  def initialize(*args, &block) # :nodoc:
116
116
  self.filters = self.class.filters.clone
117
117
  self.filters.each do |filter|
118
- self[filter.name] = filter.default
118
+ self[filter.name] = filter.default(self)
119
119
  end
120
120
  super(*args, &block)
121
121
  end
@@ -52,9 +52,23 @@ class Datagrid::Filters::BaseFilter #:nodoc:
52
52
  options[:header] || Datagrid::Utils.translate_from_namespace(:filters, grid_class, name)
53
53
  end
54
54
 
55
- def default
55
+ def default(object = nil)
56
+ unless object
57
+ Datagrid::Utils.warn_once("#{self.class.name}#default without argument is deprecated")
58
+ end
56
59
  default = self.options[:default]
57
- default.respond_to?(:call) ? default.call : default
60
+ if default.is_a?(Symbol)
61
+ if object.respond_to?(default)
62
+ object.send(default)
63
+ else
64
+ Datagrid::Utils.warn_once(":default as a Symbol is now treated as a method name. Use String instead or -> { default } if you really want default value to be a Symbol but not a String.")
65
+ default
66
+ end
67
+ elsif default.respond_to?(:call)
68
+ Datagrid::Utils.apply_args(object, &default)
69
+ else
70
+ default
71
+ end
58
72
  end
59
73
 
60
74
  def multiple
@@ -53,11 +53,18 @@ module Datagrid
53
53
  end
54
54
 
55
55
  def extract_position_from_options(array, options)
56
- position = options.extract!(:before, :after)
57
- if position[:before]
58
- array.index {|c| c.name.to_sym == position[:before].to_sym }
59
- elsif position[:after]
60
- array.index {|c| c.name.to_sym == position[:after].to_sym } + 1
56
+ before, after = options[:before], options[:after]
57
+ if before && after
58
+ raise Datagrid::ConfigurationError, "Options :before and :after can not be used together"
59
+ end
60
+ # Consider as before all
61
+ return 0 if before == true
62
+ if before
63
+ before = before.to_sym
64
+ array.index {|c| c.name.to_sym == before }
65
+ elsif after
66
+ after = after.to_sym
67
+ array.index {|c| c.name.to_sym == after } + 1
61
68
  else
62
69
  -1
63
70
  end
@@ -26,7 +26,7 @@ describe Datagrid::Columns do
26
26
  grid = test_report do
27
27
  scope {Entry}
28
28
  column(:name)
29
- column(:action, :html => true) do
29
+ column(:action, :html => true) do
30
30
  'dummy'
31
31
  end
32
32
  end
@@ -37,7 +37,7 @@ describe Datagrid::Columns do
37
37
  grid = test_report do
38
38
  scope {Entry}
39
39
  column(:name)
40
- column(:action, :html => true) do
40
+ column(:action, :html => true) do
41
41
  'dummy'
42
42
  end
43
43
  end
@@ -47,7 +47,7 @@ describe Datagrid::Columns do
47
47
  grid = test_report do
48
48
  scope {Entry}
49
49
  column(:name)
50
- column(:action, :html => true) do
50
+ column(:action, :html => true) do
51
51
  'dummy'
52
52
  end
53
53
  end
@@ -55,7 +55,7 @@ describe Datagrid::Columns do
55
55
  end
56
56
 
57
57
  describe "translations" do
58
-
58
+
59
59
  module ::Ns45
60
60
  class TranslatedReport
61
61
  include Datagrid
@@ -214,6 +214,15 @@ describe Datagrid::Columns do
214
214
  expect(report.available_columns.map(&:name)).to eq([:category])
215
215
  end
216
216
 
217
+ it "raises when :before and :after used together" do
218
+ expect do
219
+ test_report do
220
+ column(:id)
221
+ column(:name, :before => :id, :after => :name)
222
+ end
223
+ end.to raise_error(Datagrid::ConfigurationError)
224
+ end
225
+
217
226
  describe ".column_names attributes" do
218
227
  let(:grid) do
219
228
  test_report(:column_names => ["id", "name"]) do
@@ -270,7 +279,7 @@ describe Datagrid::Columns do
270
279
  first = Entry.create(:name => '1st')
271
280
  second = Entry.create(:name => '2nd')
272
281
  expect do
273
- report.attributes = {:order => :id}
282
+ report.attributes = {:order => :id}
274
283
  report.assets
275
284
  end.to raise_error(Datagrid::OrderUnsupported)
276
285
  report.attributes = {:order => :name, :descending => true}
@@ -289,6 +298,7 @@ describe Datagrid::Columns do
289
298
  fake_assets = double(:assets)
290
299
  expect(report).to receive(:assets) { fake_assets }
291
300
  expect(fake_assets).to receive(:find_each).with(batch_size: 25)
301
+ expect(fake_assets).to receive(:limit_value).and_return(nil)
292
302
  report.rows
293
303
  end
294
304
  it "should be able to disable batches" do
@@ -305,7 +315,7 @@ describe Datagrid::Columns do
305
315
  expect(fake_assets).not_to receive(:find_each)
306
316
  report.rows
307
317
  end
308
-
318
+
309
319
  it "should support instance level batch size" do
310
320
  grid = test_report do
311
321
  scope {Entry}
@@ -340,7 +350,7 @@ describe Datagrid::Columns do
340
350
  expect(row.name).to eq("Hello")
341
351
  expect {
342
352
  row.actions
343
- }.to raise_error
353
+ }.to raise_error(RuntimeError)
344
354
  end
345
355
  end
346
356
 
@@ -371,7 +381,7 @@ describe Datagrid::Columns do
371
381
  end
372
382
  grid.column(:name)
373
383
  grid
374
- end
384
+ end
375
385
 
376
386
  let(:basic_grid) { modified_grid.class.new }
377
387
  let!(:entry) { Entry.create!(:name => "Hello", :category => 'first') }
@@ -392,11 +402,16 @@ describe Datagrid::Columns do
392
402
  expect(basic_grid.rows).to eq([[entry.id]])
393
403
  end
394
404
 
395
- it "should support possitioning" do
405
+ it "should support :before column name" do
396
406
  modified_grid.column(:category, :before => :name)
397
407
  expect(modified_grid.header).to eq(["Id", "Category", "Name"])
398
408
  end
399
409
 
410
+ it "should support :before all" do
411
+ modified_grid.column(:category, :before => true)
412
+ expect(modified_grid.header).to eq(["Category", "Id", "Name"])
413
+ end
414
+
400
415
  it "should support columns block" do
401
416
  modified_grid.column(:category) do
402
417
  category.capitalize
@@ -432,7 +447,7 @@ describe Datagrid::Columns do
432
447
  describe 'dynamic helper' do
433
448
  it "should work" do
434
449
  grid = test_report do
435
- scope {Entry}
450
+ scope {Entry}
436
451
  column(:id)
437
452
  dynamic {
438
453
  column(:name)
@@ -21,6 +21,18 @@ describe Datagrid::Drivers::ActiveRecord do
21
21
  expect(scope.to_sql.strip).to eq('SELECT "entries".*, sum(entries.group_id) AS sum_group_id FROM "entries"')
22
22
  end
23
23
 
24
+ describe "Arel" do
25
+ subject do
26
+ test_report(:order => :test, :descending => true) do
27
+ scope { Entry }
28
+ column(:test, order: Arel::Nodes::Count.new(["entries.group_id"]))
29
+ end.assets
30
+ end
31
+
32
+ it "should support ordering by Arel columns" do
33
+ expect(subject.to_sql.strip).to include "ORDER BY COUNT('entries.group_id') DESC"
34
+ end
35
+ end
24
36
 
25
37
  describe "gotcha #datagrid_where_by_timestamp" do
26
38
 
@@ -50,4 +62,18 @@ describe Datagrid::Drivers::ActiveRecord do
50
62
  )
51
63
  end
52
64
  end
65
+
66
+ describe "batches usage" do
67
+
68
+ it "should be incompatible with scope with limit" do
69
+ report = test_report do
70
+ scope {Entry.limit(5)}
71
+ self.batch_size = 20
72
+ column(:id)
73
+ end
74
+ expect { report.data }.to raise_error(Datagrid::ConfigurationError)
75
+ end
76
+ end
77
+
78
+
53
79
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Datagrid::Filters::BaseFilter do
4
+
5
+
6
+ it "should support default option as block" do
7
+ report = test_report do
8
+ scope {Entry}
9
+ filter(:name, :string, :default => :name_default)
10
+ def name_default
11
+ 'hello'
12
+ end
13
+ end
14
+ expect(report.assets).to include(Entry.create!(:name => "hello"))
15
+ expect(report.assets).not_to include(Entry.create!(:name => "world"))
16
+ expect(report.assets).not_to include(Entry.create!(:name => ""))
17
+ end
18
+
19
+ end
@@ -109,7 +109,7 @@ describe Datagrid::FormBuilder do
109
109
  )}
110
110
  end
111
111
  context "with only left bound" do
112
-
112
+
113
113
  let(:_range) { [10, nil]}
114
114
  it { should equal_to_dom(
115
115
  '<input class="group_id integer_filter from" multiple name="report[group_id][]" size="30" type="text" value="10"/>' +
@@ -151,7 +151,7 @@ describe Datagrid::FormBuilder do
151
151
  it { should equal_to_dom(
152
152
  '<input class="group_id integer_filter from" multiple name="report[group_id][]" size="30" type="text"><span class="separator integer"> - </span><input class="group_id integer_filter to" multiple name="report[group_id][]" size="30" type="text">'
153
153
  ) }
154
-
154
+
155
155
  end
156
156
 
157
157
  context "when deprecated format translation specified" do
@@ -207,7 +207,7 @@ describe Datagrid::FormBuilder do
207
207
  end
208
208
  }
209
209
  context "with only left bound" do
210
-
210
+
211
211
  let(:_range) { ["2012-01-03", nil]}
212
212
  it { should equal_to_dom(
213
213
  '<input class="created_at date_filter from" multiple name="report[created_at][]" size="30" type="text" value="2012-01-03"/>' +
@@ -230,7 +230,7 @@ describe Datagrid::FormBuilder do
230
230
  )}
231
231
  end
232
232
  context "with only right bound" do
233
-
233
+
234
234
  let(:_range) { [nil, "2012-01-03"]}
235
235
  it { should equal_to_dom(
236
236
  '<input class="created_at date_filter from" multiple name="report[created_at][]" size="30" type="text"/>' +
@@ -280,7 +280,7 @@ describe Datagrid::FormBuilder do
280
280
 
281
281
  context "when block is given" do
282
282
  before(:each) do
283
- pending("not supported by rails < 4.1") if Rails.version < '4.1'
283
+ skip("not supported by rails < 4.1") if Rails.version < '4.1'
284
284
  end
285
285
  let(:_filter_block ) { proc { template.content_tag(:option, 'block option', :value => 'block_value') }}
286
286
  it { should equal_to_dom(
@@ -463,7 +463,7 @@ describe Datagrid::FormBuilder do
463
463
  column(:id)
464
464
  column(:name)
465
465
  column(:category)
466
- end
466
+ end
467
467
  end
468
468
  let(:_filter) { :column_names }
469
469
  let(:expected_html) do
@@ -494,7 +494,7 @@ describe Datagrid::FormBuilder do
494
494
  column(:id)
495
495
  column(:name)
496
496
  column(:category)
497
- end
497
+ end
498
498
  end
499
499
  let(:_filter) { :column_names }
500
500
  let(:expected_html) do
@@ -514,7 +514,7 @@ DOM
514
514
  let(:filter_options) do
515
515
  {}
516
516
  end
517
-
517
+
518
518
  let(:_grid) do
519
519
  options = filter_options
520
520
  test_report do
@@ -2,7 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe "Datagrid stylesheet" do
4
4
 
5
- pending "should work correctly" do
6
- Rails.application.assets.find_asset("datagrid")
5
+ it "should work correctly" do
6
+
7
+ if Rails.application.assets.respond_to?(:find_asset)
8
+ asset = Rails.application.assets.find_asset("datagrid")
9
+ asset
10
+ end
7
11
  end
8
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datagrid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Gusiev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -142,56 +142,56 @@ dependencies:
142
142
  requirements:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: 3.1.6
145
+ version: 3.1.7
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
- version: 3.1.6
152
+ version: 3.1.7
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: mongo_mapper
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 0.11.0
159
+ version: 0.13.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 0.11.0
166
+ version: 0.13.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: bson
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: 1.4.0
173
+ version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: 1.4.0
180
+ version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: bson_ext
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - '='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
- version: 1.4.0
187
+ version: '0'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - '='
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
- version: 1.4.0
194
+ version: '0'
195
195
  description: This allows you to easily build datagrid aka data tables with sortable
196
196
  columns and filters
197
197
  email: agresso@gmail.com
@@ -267,6 +267,7 @@ files:
267
267
  - spec/datagrid/drivers/mongo_mapper_spec.rb
268
268
  - spec/datagrid/drivers/mongoid_spec.rb
269
269
  - spec/datagrid/drivers/sequel_spec.rb
270
+ - spec/datagrid/filters/base_filter_spec.rb
270
271
  - spec/datagrid/filters/boolean_enum_filter_spec.rb
271
272
  - spec/datagrid/filters/composite_filters_spec.rb
272
273
  - spec/datagrid/filters/date_filter_spec.rb
@@ -326,7 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
326
327
  version: '0'
327
328
  requirements: []
328
329
  rubyforge_project:
329
- rubygems_version: 2.4.5
330
+ rubygems_version: 2.4.8
330
331
  signing_key:
331
332
  specification_version: 4
332
333
  summary: Ruby gem to create datagrids