列表Field屬性的巧妙運用(隱藏欄)

來源:互聯網
上載者:User

原文連結:http://www.cnblogs.com/wanghao-3/archive/2007/11/05/949535.html

              http://www.msotec.com/showtopic-916.aspx

 

SPD修改方法:

首先,開啟要改頁面的源檔案,找到要改的欄ID。

如果是顯示頁面的欄ID比較短,如: SPFieldText;如果是建立或編輯頁面的欄ID比較長,如:ctl00_ctl00_g_d43e2ae3_23c8_4cc3_ac81_912104dbd99f_ctl00_ctl04_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField

然後,可以先用IE測試一下( ***的位置就填寫ID):

javascript:alert(document.all. ***.parentElement.style.display='none')

如果在IE測試正確。用SPD開啟頁面,在加上就可以了。

<script>
document.all.***.parentElement.style.display='none';
</script>

 

這個方法還算管用,只是每隱藏一個欄都要寫一行。

 

程式修改方法:

  在實際的開發過程中,我們想在建立Item 的時候,想控制他的許可權.不想要一些人,看到一些Field,在有許可權的時候,又要看到的時候,又自動的顯示, 上面講述的是js調用..其實 moss本身就為我們考慮的很好,都給我們留下介面.我們只需要設定就可以。

 

            SPSite site = new SPSite(@"http://wh/sites/ict/icts");

            SPWeb web = site.OpenWeb();

            SPList list = web.Lists["My Request"];

            SPListItemCollection items = list.Items;

            

           //建立的時候Room No field 看不到

            list.Fields["Room No."].ShowInNewForm = false;

            list.Fields["Room No."].Update();

 

           //查看的時候,Room No. field 看不到

            list.Fields["Room No."].ShowInDisplayForm = false;

            list.Fields["Room No."].Update();

 

            //編輯的時候,Room No. field看不到。

            list.Fields["Room No."].ShowInEditForm = false;

            list.Fields["Room No."].Update();

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.