2009-01-29
■[Sharepoint]ダウンロード時に二回目以降のクリックイベントが動作しない場合の回避方法
念のためメモ。以下のURLを参考にして実装すると回避できます。
After file added to response, post back stops working in WebPart
1.以下のコードをPageクラスに追加(拡張メソッドでもよし)
protected void AlterFormSubmitEvent() { StringBuilder script = new StringBuilder(); script.AppndLine("var exportRequested = false;"); script.AppndLine("var beforeFormSubmitFunction = theForm.onsubmit;"); script.AppndLine("theForm.onsubmit = function(){"); script.AppndLine("var returnVal = beforeFormSubmitFunction();"); script.AppndLine("if(exportRequested && returnVal){_spFormOnSubmitCalled=false; exportRequested=false;}"); script.AppndLine("return returnVal;"); script.AppndLine("};"); script.AppndLine(this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alterFormSubmitEvent", script.ToString(), true)); }
2.ダウンロードするボタンのOnClientClickで「exportRequested=true;」を設定
これで二回目とか関係なく正常にクリックイベントが動作します。
これはSharepointはもともと二重送信防止の制御が入っているのが原因と思われます。
リクエスト時にフラグを立てるのでダウンロードなどリクエストをフラッシュしてしまうと
フラグが立てぱなしになってしまうからではないかと推測しています。
2009-01-01
■[雑談]謹賀新年
気がついたら2009年になってしまいました。ダラダラとテレビを見て年を越したわけだけど、今年はダラダラとせず気を引き締めていきたいところ。だからといって、このブログが活発になるかといわれると微妙ですなぁ。
去年を振り返ると上半期は仕事に忙殺されていた感じだったなぁと思う。でも、前職最後のプロジェクトにしては色んな面で気づきを得たプロジェクトだった思う。
下半期になると転職して色んな面で自分が忘れていたことに気づかされた感じ。初心を忘れちゃいかんね。あとは京都で旧友にも会えたし、他にも旅行とかライブとかそれなりに満喫できた年だったなぁって思う。
今年も自分になりにマイペースで満喫できたらって思います。
2008-12-15
■[Sharepoint]SPGridViewのバインド時にグループ表示を展開しない方法
SPGridViewでAllowGroupingを有効にするとグループ化してくれるが、デフォルトだと全展開されて表示される。
全展開しないプロパティを探したけど、どこにもなかったのでClientScript使って以下のようにすると全展開されません。
<script type="text/javascript"> var rows = document.getElementsByTagName('tr'); var numRows = rows.length; for (var i = 0; i < numRows; ++i) { if (rows[i].getAttribute("isexp") != null && rows[i].getAttribute("isexp").toLowerCase() == "true") { if(rows[i].firstChild.firstChild != null && rows[i].firstChild.firstChild.tagName.toLowerCase() == "a") { if (rows[i].firstChild.firstChild.title.toLowerCase() == "展開/折りたたむ") { rows[i].firstChild.firstChild.fireEvent("onclick"); } } } } </script>
元ネタ:Robin’s Sharepoint Blog: SPGridview and collapsed grouping by default!
2008-11-11
■[Sharepoint]SharePoint Guidance - November 2008
今ちょうどMOSSをあれこれやっているのでこれはありがたい。
家にはMOSSの開発環境はないので会社で試してみよう!!
Download: SharePoint Guidance - November 2008 - Microsoft Download Center - Download Details
