Skip to content

Commit 7289816

Browse files
committed
Pass document title to replaceState to provide parameter value
Feature check for history Add example todos
1 parent ed7f703 commit 7289816

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

Griddly/Scripts/griddly.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
var isLoadingHistory = false;
3434

35-
if (history.state && history.state.griddly)
35+
if (window.history && history.replaceState && history.state && history.state.griddly)
3636
{
3737
var state = history.state.griddly[this.options.url];
3838

@@ -930,23 +930,26 @@
930930

931931
var postData = this.buildRequest();
932932

933-
var state =
933+
if (window.history && history.replaceState)
934934
{
935-
pageNumber: this.options.pageNumber,
936-
pageSize: this.options.pageSize,
937-
sortFields: this.options.sortFields,
938-
filterMode: this.getFilterMode(),
939-
filterValues: this.getFilterValues()
940-
};
935+
var state =
936+
{
937+
pageNumber: this.options.pageNumber,
938+
pageSize: this.options.pageSize,
939+
sortFields: this.options.sortFields,
940+
filterMode: this.getFilterMode(),
941+
filterValues: this.getFilterValues()
942+
};
941943

942-
var globalState = history.state || {};
944+
var globalState = history.state || {};
943945

944-
if (!globalState.griddly)
945-
globalState.griddly = {};
946+
if (!globalState.griddly)
947+
globalState.griddly = {};
946948

947-
globalState.griddly[this.options.url] = state;
949+
globalState.griddly[this.options.url] = state;
948950

949-
history.replaceState(globalState, document.title);
951+
history.replaceState(globalState, document.title);
952+
}
950953

951954
// TODO: cancel any outstanding calls
952955

Griddly/Views/Home/Examples.cshtml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@
1717

1818
<h3>Other Random Examples/Tests</h3>
1919
@Html.Griddly("TestGrid")
20+
21+
@* TODO:
22+
Columns
23+
Buttons
24+
Filters
25+
Selection
26+
Grid settings
27+
Exports
28+
LINQ results
29+
Dapper results
30+
Templating
31+
Server hooks
32+
Client events
33+
Client methods
34+
*@
2035
</div>
2136
</div>
2237
<script>
@@ -54,7 +69,7 @@
5469
var grid = $(".griddly.filter-list-grid");
5570
var table = grid.find("table");
5671
57-
72+
5873
// some basic changes to make the grid more conducive to scrolling
5974
grid.find(".griddly-scrollable-container").css({ "overflow": "auto", "height": "250px" });
6075
grid.find("thead td").css({ "background-color": "white" });
@@ -72,7 +87,7 @@
7287
7388
grid.griddly("pageSize", 20);
7489
grid.griddly("refresh");
75-
90+
7691
return false;
7792
}
7893
</script>

0 commit comments

Comments
 (0)