Skip to content

Commit 4a6bdd5

Browse files
authored
Merge pull request #203 from quantopian/object-display
1.0.6 beta 6
2 parents 19e135e + 5b9ffe0 commit 4a6bdd5

File tree

7 files changed

+300
-48
lines changed

7 files changed

+300
-48
lines changed

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qgrid",
3-
"version": "1.0.5",
3+
"version": "1.0.6-beta.6",
44
"description": "An Interactive Grid for Sorting and Filtering DataFrames in Jupyter Notebook",
55
"author": "Quantopian Inc.",
66
"main": "src/index.js",

js/src/qgrid.css

Lines changed: 86 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@
186186
border-right: none;
187187
}
188188

189-
.q-grid .slick-header-columns {
189+
.q-grid .slick-header-columns,
190+
.text-filter-grid .slick-header-columns {
190191
background: none;
191192
background-color: rgb(245, 245, 245);
192193
border-bottom: none;
@@ -286,12 +287,12 @@
286287
.q-grid .slick-cell {
287288
border-bottom: 1px solid #e1e8ed;
288289
border-right: none;
289-
border-top: 1px solid transparent;
290290
border-left: 1px solid transparent;
291291
font-size: 13px;
292292
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
293-
padding-top: 3px;
294293
padding-left: 0px;
294+
padding-top: 4px;
295+
border-top: none;
295296
}
296297

297298
.q-grid.highlight-selected-row .slick-cell.selected {
@@ -322,11 +323,69 @@
322323

323324
.q-grid .slick-cell.idx-col {
324325
font-weight: bold;
326+
margin-right: 3px;
327+
}
328+
329+
.q-grid .slick-cell.idx-col.last-idx-col {
330+
border-right: 1px solid rgb(225, 232, 237);
331+
}
332+
333+
.q-grid .slick-cell.idx-col:not(.first-idx-col) {
334+
font-weight: bold;
335+
border-left: 1px solid rgb(225, 232, 237);
336+
margin-right: 3px;
337+
}
338+
339+
.q-grid .idx-col.group-top {
340+
border-bottom-color: transparent;
341+
background-color: #FFF;
342+
}
343+
344+
.q-grid .idx-col.group-middle {
345+
border-top-color: transparent;
346+
border-bottom-color: transparent;
347+
color: transparent;
348+
background-color: #FFF;
349+
}
350+
351+
.q-grid .idx-col.group-bottom {
352+
border-top-color: transparent;
353+
color: transparent;
354+
background-color: #FFF;
355+
}
356+
357+
.q-grid .idx-col.group-single {
358+
background-color: transparent;
325359
}
326360

327361
.q-grid .slick-cell.l0.r0 {
328362
border-left: none;
329363
padding-left: 6px;
364+
z-index: 85;
365+
}
366+
367+
.q-grid .slick-cell.l1.r1 {
368+
z-index: 86;
369+
}
370+
371+
.q-grid .slick-cell.l2.r2 {
372+
z-index: 87;
373+
}
374+
375+
.q-grid .slick-cell.l3.r3 {
376+
z-index: 88;
377+
}
378+
379+
.q-grid .slick-cell.l4.r4 {
380+
z-index: 89;
381+
}
382+
383+
.q-grid .slick-cell.l5.r5 {
384+
z-index: 90;
385+
}
386+
387+
.q-grid .slick-cell.editable {
388+
z-index: 91 !important;
330389
}
331390

332391
.q-grid .slick-cell.selected {
@@ -577,7 +636,7 @@
577636
z-index: 9999 !important;
578637
}
579638

580-
#ui-datepicker-div .ui-datepicker {
639+
#ui-datepicker-div.ui-datepicker {
581640
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
582641
/*@include box-shadow(0 5px 10px rgba(0, 0, 0, 0.2))*/
583642
z-index: 99 !important;
@@ -586,6 +645,27 @@
586645
border: 1px solid gray;
587646
}
588647

648+
#ui-datepicker-div.ui-datepicker .ui-icon {
649+
display: inline-block;
650+
font: normal normal normal 14px/1 FontAwesome;
651+
font-size: inherit;
652+
text-rendering: auto;
653+
-webkit-font-smoothing: antialiased;
654+
-moz-osx-font-smoothing: grayscale;
655+
text-indent: 0px;
656+
margin-left: -4px;
657+
margin-top: -6px;
658+
background-image: none;
659+
}
660+
661+
#ui-datepicker-div.ui-datepicker .ui-icon-circle-triangle-w:before {
662+
content: "\f053";
663+
}
664+
665+
#ui-datepicker-div.ui-datepicker .ui-icon-circle-triangle-e:before {
666+
content: "\f054";
667+
}
668+
589669

590670
/* from slickgrid editing example */
591671
input.editor-text {
@@ -641,5 +721,6 @@ input.bool-filter-radio {
641721
}
642722

643723
.slick-row .slick-cell:not(:first-child) {
644-
padding-left: 4px;
724+
padding-left: 5px;
725+
margin-left: -4px;
645726
}

js/src/qgrid.datefilter.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ class DateFilter extends filter_base.FilterBase {
8383
var end_date_string = this.end_date_control.val();
8484

8585
var start_date = new Date(start_date_string);
86+
var end_date = new Date(end_date_string);
8687

87-
// use the last millisecond of the end_date (1000ms * 60s * 60m * 24h)
88-
var end_date = new Date(
89-
(new Date(end_date_string).getTime()) + (1000 * 60 * 60 * 24) - 1
90-
);
88+
start_date = Date.UTC(start_date.getUTCFullYear(), start_date.getUTCMonth(), start_date.getUTCDate());
89+
end_date = Date.UTC(end_date.getUTCFullYear(), end_date.getUTCMonth(), end_date.getUTCDate());
90+
end_date += (1000 * 60 * 60 * 24) - 1;
9191

92-
this.filter_start_date = start_date.getTime();
93-
this.filter_end_date = end_date.getTime();
92+
this.filter_start_date = start_date;
93+
this.filter_end_date = end_date;
9494

9595
this.send_filter_changed();
9696

@@ -112,8 +112,22 @@ class DateFilter extends filter_base.FilterBase {
112112

113113
this.filter_elem.find(".datepicker").datepicker(date_options);
114114

115-
this.start_date_control.datepicker("setDate", this.min_date);
116-
this.end_date_control.datepicker("setDate", this.max_date);
115+
if (this.filter_start_date != null){
116+
this.start_date_control.datepicker("setDate", this.get_utc_date(this.filter_start_date));
117+
} else {
118+
this.start_date_control.datepicker("setDate", this.min_date);
119+
}
120+
121+
if (this.filter_end_date != null){
122+
this.end_date_control.datepicker("setDate", this.get_utc_date(this.filter_end_date));
123+
} else {
124+
this.end_date_control.datepicker("setDate", this.max_date);
125+
}
126+
}
127+
128+
get_utc_date(date_ms) {
129+
var date = new Date(date_ms);
130+
return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
117131
}
118132

119133
get_filter_info() {

js/src/qgrid.widget.js

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class QgridModel extends widgets.DOMWidgetModel {
3636
_view_name : 'QgridView',
3737
_model_module : 'qgrid',
3838
_view_module : 'qgrid',
39-
_model_module_version : '^1.0.5',
40-
_view_module_version : '^1.0.5',
39+
_model_module_version : '^1.0.6-beta.6',
40+
_view_module_version : '^1.0.6-beta.6',
4141
_df_json: '',
4242
_columns: {}
4343
});
@@ -204,6 +204,7 @@ class QgridView extends widgets.DOMWidgetView {
204204
this.data_view = this.create_data_view(df_json.data);
205205
this.grid_options = this.model.get('grid_options');
206206
this.index_col_name = this.model.get("_index_col_name");
207+
this.row_styles = this.model.get("_row_styles");
207208

208209
this.columns = [];
209210
this.index_columns = [];
@@ -301,7 +302,9 @@ class QgridView extends widgets.DOMWidgetView {
301302
$.datepicker.setDefaults({
302303
gotoCurrent: true,
303304
dateFormat: $.datepicker.ISO_8601,
304-
constrainInput: false
305+
constrainInput: false,
306+
"prevText": "",
307+
"nextText": ""
305308
});
306309

307310
var sorted_columns = Object.values(columns).sort(
@@ -346,6 +349,15 @@ class QgridView extends widgets.DOMWidgetView {
346349
if (cur_column.is_index) {
347350
slick_column.editor = editors.IndexEditor;
348351
slick_column.cssClass += ' idx-col';
352+
if (cur_column.first_index){
353+
slick_column.cssClass += ' first-idx-col';
354+
}
355+
if (cur_column.last_index){
356+
slick_column.cssClass += ' last-idx-col';
357+
}
358+
359+
slick_column.name = cur_column.index_display_text;
360+
slick_column.level = cur_column.level;
349361
this.index_columns.push(slick_column);
350362
continue;
351363
}
@@ -386,6 +398,7 @@ class QgridView extends widgets.DOMWidgetView {
386398
}, 1);
387399

388400
this.slick_grid.setSelectionModel(new Slick.RowSelectionModel());
401+
this.slick_grid.setCellCssStyles("grouping", this.row_styles);
389402
this.slick_grid.render();
390403

391404
var render_header_cell = (e, args) => {
@@ -469,7 +482,7 @@ class QgridView extends widgets.DOMWidgetView {
469482
};
470483
this.send(msg);
471484
this.viewport_timeout = null;
472-
}, 100);
485+
}, 10);
473486
});
474487

475488
// set up callbacks
@@ -631,6 +644,8 @@ class QgridView extends widgets.DOMWidgetView {
631644
}
632645
this.update_timeout = setTimeout(() => {
633646
var df_json = JSON.parse(this.model.get('_df_json'));
647+
this.row_styles = this.model.get("_row_styles");
648+
this.multi_index = this.model.get("_multi_index");
634649
var data_view = this.create_data_view(df_json.data);
635650

636651
if (msg.triggered_by == 'sort_changed' && this.sort_indicator){
@@ -649,6 +664,23 @@ class QgridView extends widgets.DOMWidgetView {
649664
}
650665

651666
this.set_data_view(data_view);
667+
668+
var skip_grouping = false;
669+
if (this.multi_index) {
670+
for (var i=1; i < this.filter_list.length; i++) {
671+
var cur_filter = this.filter_list[i];
672+
if (cur_filter.is_active()) {
673+
skip_grouping = true;
674+
}
675+
}
676+
}
677+
678+
if (skip_grouping) {
679+
this.slick_grid.removeCellCssStyles("grouping");
680+
} else {
681+
this.slick_grid.setCellCssStyles("grouping", this.row_styles);
682+
}
683+
652684
this.slick_grid.render();
653685

654686
if ((msg.triggered_by == 'add_row' ||
@@ -674,7 +706,7 @@ class QgridView extends widgets.DOMWidgetView {
674706
'rows': selected_rows,
675707
'type': 'selection_changed'
676708
});
677-
}, 100);
709+
}, 10);
678710
} else if (msg.col_info) {
679711
var filter = this.filters[msg.col_info.name];
680712
filter.handle_msg(msg);

qgrid/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version_info = (1, 0, 5, 'final')
1+
version_info = (1, 0, 6, 'beta', 6)
22

33
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
44

0 commit comments

Comments
 (0)