mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR GridField JS API for updating state
This commit is contained in:
parent
47ac047454
commit
1b42b2afa7
@ -713,6 +713,11 @@ class GridField_Action extends FormAction {
|
|||||||
* @return string HTML tag
|
* @return string HTML tag
|
||||||
*/
|
*/
|
||||||
public function Field() {
|
public function Field() {
|
||||||
|
Requirements::javascript(SAPPHIRE_DIR.'/thirdparty/jquery/jquery.js');
|
||||||
|
Requirements::javascript(SAPPHIRE_DIR.'/thirdparty/json-js/json2.js');
|
||||||
|
Requirements::javascript(SAPPHIRE_DIR.'/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
||||||
|
Requirements::javascript('sapphire/javascript/GridField.js');
|
||||||
|
|
||||||
// Store state in session, and pass ID to client side
|
// Store state in session, and pass ID to client side
|
||||||
$state = array(
|
$state = array(
|
||||||
'grid' => $this->getNameFromParent(),
|
'grid' => $this->getNameFromParent(),
|
||||||
|
@ -54,9 +54,6 @@ class GridFieldFilter implements GridField_HTMLProvider, GridField_DataManipulat
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getHTMLFragments($gridField) {
|
public function getHTMLFragments($gridField) {
|
||||||
Requirements::javascript(SAPPHIRE_DIR.'/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
|
||||||
Requirements::javascript('sapphire/javascript/GridField.js');
|
|
||||||
|
|
||||||
$forTemplate = new ArrayData(array());
|
$forTemplate = new ArrayData(array());
|
||||||
$forTemplate->Fields = new ArrayList;
|
$forTemplate->Fields = new ArrayList;
|
||||||
|
|
||||||
|
@ -83,9 +83,6 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getHTMLFragments($gridField) {
|
public function getHTMLFragments($gridField) {
|
||||||
Requirements::javascript(SAPPHIRE_DIR.'/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
|
||||||
Requirements::javascript(SAPPHIRE_DIR.'/javascript/GridField.js');
|
|
||||||
|
|
||||||
$forTemplate = new ArrayData(array());
|
$forTemplate = new ArrayData(array());
|
||||||
$forTemplate->Fields = new ArrayList;
|
$forTemplate->Fields = new ArrayList;
|
||||||
|
|
||||||
|
@ -13,9 +13,6 @@ class GridFieldSortableHeader implements GridField_HTMLProvider, GridField_DataM
|
|||||||
* Returns the header row providing titles with sort buttons
|
* Returns the header row providing titles with sort buttons
|
||||||
*/
|
*/
|
||||||
public function getHTMLFragments($gridField) {
|
public function getHTMLFragments($gridField) {
|
||||||
Requirements::javascript(SAPPHIRE_DIR.'/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
|
|
||||||
Requirements::javascript(SAPPHIRE_DIR.'/javascript/GridField.js');
|
|
||||||
|
|
||||||
$forTemplate = new ArrayData(array());
|
$forTemplate = new ArrayData(array());
|
||||||
$forTemplate->Fields = new ArrayList;
|
$forTemplate->Fields = new ArrayList;
|
||||||
|
|
||||||
|
@ -3,6 +3,21 @@ jQuery(function($){
|
|||||||
$('fieldset.ss-gridfield').entwine({
|
$('fieldset.ss-gridfield').entwine({
|
||||||
getItems: function() {
|
getItems: function() {
|
||||||
return this.find('.ss-gridfield-item');
|
return this.find('.ss-gridfield-item');
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {String}
|
||||||
|
* @param {Mixed}
|
||||||
|
*/
|
||||||
|
setState: function(k, v) {
|
||||||
|
var state = this.getState();
|
||||||
|
state[k] = v;
|
||||||
|
this.find(':input[name="' + this.data('name') + '[GridState]"]').val(JSON.stringify(state));
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
|
getState: function() {
|
||||||
|
return JSON.parse(this.find(':input[name="' + this.data('name') + '[GridState]"]').val());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user