Hi all
Does anyone know if a list of radio buttons can be ordered by either attribute order, or a property called order? When i try to apply the ordering attribute, it reverts to using the DTC as the displayable text
wondering if this should be raised as bug?
Hi Kevin,
Is this the standard “Input radio” presenter?
The “Lookup preprocessor” and “Order by” options look out of place in this context. Could you post the full settings panel maybe, to see if anything else stands out?
It’s selecting a certificate type from another object (as it requires additional data like price), so not getting the data from a regular choice datatype
oh, i’ve just realised this is a custom presenter! Here is the code, if you are able to assist? /* Main server-side presenter code */
return {
get_template_data: function() {
// Init
var options = [];
// Get settings
var fragment_settings = presenter.get_fragment_settings() || {};
//cs.log(fragment_settings);
var presenter_settings = presenter.get_settings() || {};
var title_field_path = fragment_settings['title_field_path'] || '';
var field_title = fragment_settings['main_label'] || '';
var req = fragment_settings['required'] || false;
// Prepare record search
var relation_path = presenter.get_relation_path();
var relation_path_info = cs.path_info(relation_path);
var target_object_id = relation_path_info['target_object_id'];
var params = {
'base_object_id': target_object_id,
'selects': {
'id': ':id',
'title': title_field_path,
},
'filters': [],
'groupings': [],
'return': 'data',
};
// Limit by subset?
if (fragment_settings['limit_subset_field_path'] || false) {
params['filters'].push({
'field_path': fragment_settings['limit_subset_field_path'],
'value': 1,
});
}
// Limit via path?
if (fragment_settings['limit_relation_path'] || false) {
var limit_relation_path = fragment_settings['limit_relation_path'];
var limit_relation_path_info = cs.path_info(limit_relation_path);
var reverse_limit_relation_path = limit_relation_path_info['reverse'];
params['filters'].push({
'field_path': reverse_limit_relation_path + ':id',
'value': presenter.get_base_record_id(),
});
}
// Exclude via path?
if (fragment_settings['exclusion_relation_path'] || false) {
var exclusion_relation_path = fragment_settings['limit_relation_path'];
var exclusion_relation_path_info = cs.path_info(exclusion_relation_path);
var reverse_exclusion_relation_path = exclusion_relation_path_info['reverse'];
params['filters'].push({
'field_path': reverse_exclusion_relation_path + ':id',
'comparison_operator': 'not_equal_to',
'value': presenter.get_base_record_id(),
});
}
// Set order
params['order'] = [{
'field_path': fragment_settings['order_field_path'] || fragment_settings['title_field_path'],
'direction': fragment_settings['order_direction'] || 'ASC',
}];
// Fetch records
var options = cs.search(params);
// cs.log(JSON.stringify(options));
return {
options,
current_value: presenter.get_editable_value(),
req
}
},
get_settings: function() {
return {
}
},
}
I notice there is some code to set the order, but looks like there may be a bug in it
Nothing immediately stands out as wrong here, the ordering logic seems simple enough, but obviously there are other files involved too. Maybe an issue in the frontend code possibly, if it’s causing the wrong text to be shown for the options. Is frontend.js doing anything with the options data maybe?