I am trying to use a snippet and a custom button to export model data to excel but I have a couple things I am stuck on. I am mainly doing this because I want to export fields that are outside my table but do not want to append the record id. It seems I can’t do both point and click.
1. When using a snippet, how do I add custom labels to the fields? Is this possible?
2. When using this method it seems I lose the functionality of selecting which rows I want to export. Is this true? Can you only export all rows?
Here’s my sample snippet:
var model = skuid.model.getModel(‘Estimates’);
model.exportData({
fileName: ‘All_Estimates’,
usetablecolumns:“false”,
fields: [
model.getField(‘Estimate__r.Name’),
model.getField(‘Estimate__r.Description__c’),
model.getField(‘Estimate__r.Location__r.Name’),
model.getField(‘Status__c’),
model.getField(‘Estimate__r.Status__c’)
],
doNotAppendRowIdColumn: true,
});
Hi Ryan
Try this:
var $ = skuid.$;<br /><br />var model = skuid.model.getModel('Estimates'),<br /> TABLE_UNIQUE_ID = 'yourTableId',<br /> list = skuid.$('#'+TABLE_UNIQUE_ID).data('object').list,<br /> selectedRows = skuid.$.map(list.getSelectedItems(),function(item){ <br /> return item.row; <br /> });<br /><br />var estName = model.getField('Estimate__r.Name'),<br /> estDesc = model.getField('Estimate__r.Description__c');<br />estName.label = 'yourlabel';<br />estDesc.label = 'yourlabel';<br /><br />model.exportData({<br /><br /> fileName: 'All_Estimates',<br /><br /> fields: [<br /> estName,<br /> estDesc<br /> ],<br /><br /> rows: selectedRows,<br /> <br /> doNotAppendRowIdColumn: true,<br /><br />});
Add the rest of your fields to the code.
This will export all rows, which you selected in the table (Like a mass action).
Hope that helps…
Thank you!
Tried this. Didn’t work for me.