PDA

View Full Version : Show Field as Column in Listing Manager



Kristopher Catterall
December 3, 2012, 02:53 PM
I would like to be able to display a field (yes or no value) in the listing manager as a column, similar to the active inactive column. How would I get this to show?

Thank You

Vladimir
December 4, 2012, 03:35 AM
Hello,

You can use as an example the field status. (please see admin/js/ext/rlGrid.js -> line 81-119)

Kristopher Catterall
December 4, 2012, 08:10 PM
Where do the dataIndex come from? ie what file has the data in it.

Brandon

Mike
December 7, 2012, 06:05 AM
Hello,

Take a look into the admin/tpl/controllers/listings.tpl

there is peace of code to create extJs grid object starting with




var listingsGrid;
$(document).ready(function(){

listingsGrid = new gridObj({
key: 'listings',



As Vladimir said you can easily do it through copying existing Status column and make appropriate changes



,{
header: lang['ext_status'],
dataIndex: 'Status',
width: 100,
fixed: true,
editor: new Ext.form.ComboBox({
store: [
['active', lang['ext_active']],
['approval', lang['ext_approval']]
],
mode: 'local',
typeAhead: true,
triggerAction: 'all',
selectOnFocus: true
}),
renderer: function(val) {
return '<div ext:qtip="'+lang['ext_click_to_edit']+'">'+val+'</div>';
}
},



change something like





,{
header: lang['ext_status'], //change name of column here
dataIndex: 'Status', //this is link to the data , comes from the mapping section
width: 100,
fixed: true,
editor: new Ext.form.ComboBox({
store: [
['active', lang['ext_active']], // these two lines are possible values of the dropdown
['approval', lang['ext_approval']]
],
mode: 'local',
typeAhead: true,
triggerAction: 'all',
selectOnFocus: true
}),
renderer: function(val) {
return '<div ext:qtip="'+lang['ext_click_to_edit']+'">'+val+'</div>';
}
},



dataIndex comes from here, fields section (mapping), you have to add your field to this section



fields: [
{name: 'ID', mapping: 'ID', type: 'int'},
...
{name: 'Status', mapping: 'Status'},

],


also you have to add your field to the admin/controllers/listings.inc.php
find code and add your field to the list


$transfer_fields = array('ID', 'Status', 'title', 'Type', 'Cat_title', 'Plan_ID', 'Pay_date', 'Username', 'Account_ID', 'Date', 'Allow_photo', 'Allow_video');