Handle num_rows set by application:

- Don't overwrite num_rows setting if the application sets it for some reason
- If num_rows is 0, don't get the initial rows server side
- If num_rows is 0 and the initial rows are missing, trigger an update right away to get them asyncronously.
This commit is contained in:
Nathan Gray 2014-07-28 21:00:39 +00:00
parent 9851a8a6ef
commit 8a70df4df8
2 changed files with 17 additions and 3 deletions

View File

@ -113,7 +113,11 @@ class etemplate_widget_nextmatch extends etemplate_widget
$value = self::get_array(self::$request->content, $form_name, true);
$value['start'] = 0;
$value['num_rows'] = self::INITIAL_ROWS;
if(!array_key_exists('num_rows',$value))
{
$value['num_rows'] = self::INITIAL_ROWS;
}
$value['rows'] = array();
$send_value = $value;
@ -159,7 +163,10 @@ class etemplate_widget_nextmatch extends etemplate_widget
$send_value['order'] = $send_value['sort']['id'];
$send_value['sort'] = $send_value['sort']['asc'] ? 'ASC' : 'DESC';
}
$total = self::call_get_rows($send_value, $send_value['rows'], self::$request->readonlys);
if($value['num_rows'] != 0)
{
$total = self::call_get_rows($send_value, $send_value['rows'], self::$request->readonlys);
}
$value =& self::get_array(self::$request->content, $form_name, true);
// Add favorite here so app doesn't save it in the session

View File

@ -1082,7 +1082,7 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput],
this.dataview.grid.setTotalCount(total);
// Insert any data sent from server, so invalidate finds data already
if(this.options.settings.rows)
if(this.options.settings.rows && this.options.settings.num_rows)
{
this.controller.loadInitialData(
this.options.settings.dataStorePrefix,
@ -1510,6 +1510,13 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput],
// Set filters to current values
this.controller.setFilters(this.activeFilters);
// If no data was sent from the server, and num_rows is 0, the nm will be empty.
// This triggers a cache check.
if(!(this.options.settings.rows && this.options.settings.num_rows))
{
this.controller.update();
}
// Load the default sort order
if (this.options.settings.order && this.options.settings.sort)
{