BCS 字段顯示格式化

技術部分
1.使用SPD添加外部數據源時保證,安裝SPD的客戶機在 同一個域中,而且在管理中心給Business Data Connectivity Service 受權
 
2.生成的外部數據無法再後臺進行格式化,只能在SPD中對外部列表進行處理;
日期類型會映射爲時間類型(會顯示時間部分),處理方式爲在外部列表中 修改 視圖  和  新建  全部窗體:
視圖:修改
時間字段: ddwrt:FormatDate(string($thisNode/@*[name()=current()/@Name]),2052,3)
money字段: format-number($thisNode/@*[name()=current()/@Name],'0.00')

窗體:刪除新建

1.顯示窗體
日期字段:<xsl:value-of select="ddwrt:FormatDate(string(@PublicDate),2052,3)"/>
money類型會映射成Decimal(會顯示4位小時),處理方式爲在外部列表中新建顯示頁面,格式化成2位小數:<xsl:value-of select="format-number(@NB,'0.00')"/>
2.新建窗體
日期字段:經過腳本隱藏和賦默認值值
<script type="text/javascript">                
  document.getElementById(g_strDateTimeControlIDs[&quot;SPPublicDate&quot;]).value= new Date().format(&quot;yyyy/MM/dd&quot;); 
  document.getElementById(g_strDateTimeControlIDs[&quot;SPPublicDate&quot;] + &quot;Hours&quot;).style.display = &quot;none&quot;;       
  document.getElementById(g_strDateTimeControlIDs[&quot;SPPublicDate&quot;] + &quot;Minutes&quot;).style.display = &quot;none&quot;;
  
  // 對Date的擴展,將 Date 轉化爲指定格式的String 
// 月(M)、日(d)、小時(h)、分(m)、秒(s)、季度(q) 能夠用 1-2 個佔位符, 
// 年(y)能夠用 1-4 個佔位符,毫秒(S)只能用 1 個佔位符(是 1-3 位的數字) 
// 例子: 
// (new Date()).Format(&quot;yyyy-MM-dd hh:mm:ss.S&quot;) ==&gt; 2006-07-02 08:09:04.423 
// (new Date()).Format(&quot;yyyy-M-d h:m:s.S&quot;)      ==&gt; 2006-7-2 8:9:4.18 
Date.prototype.Format = function(fmt) 
{ //author: meizz 
  var o = { 
    &quot;M+&quot; : this.getMonth()+1,                 //月份 
    &quot;d+&quot; : this.getDate(),                    //日 
    &quot;h+&quot; : this.getHours(),                   //小時 
    &quot;m+&quot; : this.getMinutes(),                 //分 
    &quot;s+&quot; : this.getSeconds(),                 //秒 
    &quot;q+&quot; : Math.floor((this.getMonth()+3)/3), //季度 
    &quot;S&quot;  : this.getMilliseconds()             //毫秒 
  }; 
  if(/(y+)/.test(fmt)) 
    fmt=fmt.replace(RegExp.$1, (this.getFullYear()+&quot;&quot;).substr(4 - RegExp.$1.length)); 
  for(var k in o) 
    if(new RegExp(&quot;(&quot;+ k +&quot;)&quot;).test(fmt)) 
  fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : ((&quot;00&quot;+ o[k]).substr((&quot;&quot;+ o[k]).length))); 
  return fmt; 
}
</script>

3.編輯窗體
日期字段: 經過腳本隱藏,無需賦值

////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
應用部分
1.適用於文本內容爲主的信息,涉及到數字、時間類型就比較難處理;
2.適用於查看信息,若是要對內容進行增刪改操做則體驗很差;


相關文章
相關標籤/搜索