// format the params
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['rowCount'] = $params['rp'];
- $params['sort'] = CRM_Utils_Array::value('sortBy', $params);
$field = CRM_Core_BAO_CustomField::getFieldObject($params['fid']);
$params['total'] = CRM_Core_DAO::singleValueQuery($total, $queryParams);
$limit = " LIMIT {$params['offset']}, {$params['rowCount']} ";
-
$orderBy = ' ORDER BY options.weight asc';
- if (!empty($params['sort'])) {
- $orderBy = ' ORDER BY ' . CRM_Utils_Type::escape($params['sort'], 'String');
- }
$query = "SELECT * FROM civicrm_option_value as options WHERE option_group_id = %1 {$orderBy} {$limit}";
$dao = CRM_Core_DAO::executeQuery($query, $queryParams);
public static function getOptionList() {
$params = $_REQUEST;
- $sortMapper = array(
- 0 => 'options.label',
- 1 => 'options.value',
- 2 => '',
- 3 => '',
- 4 => '',
- );
-
$sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
$offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
$rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
- $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
- $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
-
- if ($sort && $sortOrder) {
- $params['sortBy'] = $sort . ' ' . $sortOrder;
- }
$params['page'] = ($offset / $rowCount) + 1;
$params['rp'] = $rowCount;
OR id = $endid";
}
CRM_Core_DAO::executeQuery($updateRows, $queryParams);
+ CRM_Utils_JSON::output(TRUE);
}
}
<th class='crm-custom_option-label'>{ts}Label{/ts}</th>
<th class='crm-custom_option-value'>{ts}Value{/ts}</th>
<th class='crm-custom_option-default_value'>{ts}Default{/ts}</th>
- <th class='crm-custom_option-is_active nosort'>{ts}Enabled?{/ts}</th>
+ <th class='crm-custom_option-is_active'>{ts}Enabled?{/ts}</th>
<th class='crm-custom_option-links'> </th>
<th class='hiddenElement'> </th>
</tr>
"aoColumns" : [
{sClass:'crm-custom_option-label'},
{sClass:'crm-custom_option-value'},
- {sClass:'crm-custom_option-default_value', bSortable:false},
- {sClass:'crm-custom_option-is_active', bSortable:false},
- {sClass:'crm-custom_option-links', bSortable:false},
- {sClass:'hiddenElement', bSortable:false}
+ {sClass:'crm-custom_option-default_value'},
+ {sClass:'crm-custom_option-is_active'},
+ {sClass:'crm-custom_option-links'},
+ {sClass:'hiddenElement'}
],
"bProcessing": true,
"asStripClasses" : [ "odd-row", "even-row" ],
"sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
"bServerSide": true,
"bJQueryUI": true,
+ "bSort" : false,
"sAjaxSource": sourceUrl,
"iDisplayLength": 10,
"oLanguage": {
var id = $('td:last', nRow).text().split(',')[0];
var cl = $('td:last', nRow).text().split(',')[1];
$(nRow).addClass(cl).attr({id: 'OptionValue-' + id});
- $('td:eq(0)', nRow).wrapInner('<span class="crm-editable crmf-label" />');
+ $('td:eq(0)', nRow).wrapInner('<div class="crm-editable crmf-label" />');
+ $('td:eq(0)', nRow).prepend('<div style="cursor:move" class="icon ui-icon-grip-dotted-vertical">');
$('td:eq(2)', nRow).addClass('crmf-default_value');
return nRow;
},
});
}
+
var startPosition;
var endPosition;
var gid = {/literal}'{$optionGroupID}'{literal};
$("table.crm-option-selector tbody").sortable({
+ handle: ".ui-icon-grip-dotted-vertical",
cursor: "move",
start:function(event, ui) {
var oSettings = $('table.crm-option-selector').dataTable().fnSettings();
end: endPosition,
gid: gid
})
+ .success(function() {
+ oSettings.oApi._fnDraw(oSettings);
+ CRM.status(ts('Saved'));
+ });
}
});
});