wando_grid 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/wando_grid.rb +14 -18
- metadata +1 -1
data/lib/wando_grid.rb
CHANGED
|
@@ -9,10 +9,6 @@ module WandoGrids
|
|
|
9
9
|
# loadData: 是否自动加载数据
|
|
10
10
|
|
|
11
11
|
# wando_grid的入口函数,返回请求记录,和记录总数
|
|
12
|
-
def hello
|
|
13
|
-
puts "world"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
12
|
def wando_grid(params, object, option = {}, toLoadData = true)
|
|
17
13
|
object, result = wando_grid_in_json(params, object, option, toLoadData)
|
|
18
14
|
|
|
@@ -144,24 +140,24 @@ module WandoGrids
|
|
|
144
140
|
fs
|
|
145
141
|
end
|
|
146
142
|
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
def wando_grid_for_array params, array
|
|
144
|
+
fields, column_name, result = [], [], []
|
|
149
145
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
146
|
+
relations = JSON.parse(params[:columnsConfig])
|
|
147
|
+
relations.each do |o ,e|
|
|
148
|
+
fields << e
|
|
149
|
+
column_name << o
|
|
150
|
+
end
|
|
155
151
|
|
|
156
|
-
|
|
157
|
-
|
|
152
|
+
column_name.push("id")
|
|
153
|
+
records = array.provide(*column_name)
|
|
158
154
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
records.each do |r|
|
|
156
|
+
result << Hash[r.map {|k, v| [relations[k], v] }]
|
|
157
|
+
end
|
|
162
158
|
|
|
163
|
-
|
|
159
|
+
render :json => { :success => true, :total => array.count, :result => result }
|
|
164
160
|
|
|
165
|
-
|
|
161
|
+
end
|
|
166
162
|
|
|
167
163
|
end
|