我正在尝试通过电子邮件发送一个表格,该表格将在单击该列时根据该列进行排序。
我找到了http://tablesorter.com/docs/,它看起来很简单。
我正在使用python编写html。有问题的功能是
def getOpportunitiesTable(opps): #formats html table for email
它接受一个dict列表并应该返回html
html = ""
html += "<head>"
html += '<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>'
html += '<script type="text/javascript" src="http://mottie.github.com/tablesorter/js/jquery.tablesorter.js"></script>'
html += "</head>"
html += '<table id="opportunities" class="tablesorter">'
html += '<thead><tr><th>Opportunity Name</th><th>Forcasted Close Date</th><th>Pipeline Category</th><th>Stage</th><th>Priority</th></tr></thead>'
html += '<tbody>'
for o in iter(opps):
html += "<tr>"
#opportunity name linked to insightly's page
html += "<td>" + '<a href="https://googleapps.insight.ly/Opportunities/Details/' + str(o['OPPORTUNITY_ID']) + '">'
try:
html += o['OPPORTUNITY_NAME'].encode('utf-8')
except:
html += '************************'
logging.info(str(o))
html += "</a>" + "</td>"
html += "<td>"
if 'FORECAST_CLOSE_DATE' in o and o["FORECAST_CLOSE_DATE"] != None: #if fclose date provided format it
html += datetime.strptime(o["FORECAST_CLOSE_DATE"], '%Y-%m-%d %H:%M:%S').strftime('%Y-%m-%d')
else:
html += ' - '
html += "</td>"
html += "<td>" + pipelineCategory[o['PIPELINE_ID']] if o['PIPELINE_ID'] in pipelineCategory else ' - ' + "</td>"
html += "<td>" + stageName[o['STAGE_ID']] if o['STAGE_ID'] in stageName else ' - ' + "</td>"
html += "<td>" + str(o["OPPORTUNITY_FIELD_5"]) + "</td>"
html += "</tr>"
html += '</tbody>'
html += "</table><br/>"
return html
我的困惑来自这两行
html += '<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>'
html += '<script type="text/javascript" src="http://mottie.github.com/tablesorter/js/jquery.tablesorter.js"></script>'
还有一个固有的问题是我应该被允许发送操纵发送的表格的html电子邮件吗?
任何帮助表示赞赏!