コード例 #1
0
ファイル: Rendering.cs プロジェクト: webgrid/WebGrid
        private static void StartNewRow(Row row, string style, WebGridHtmlWriter writer)
        {
            Grid grid = row.m_Table.m_Grid;
            StringBuilder js = new StringBuilder(string.Empty);
            string onmouseover = string.Empty;
            string onmouseout = string.Empty;

            if (grid.RowHighLight != Color.Empty)
            {
                row.RowHighLight = grid.RowHighLight;

                if (row.RowHighLight != Color.Empty)
                {
                    onmouseover += string.Format("wgrowhighlight(this, 'over', '{0}');", Grid.ColorToHtml(grid.RowHighLight));
                    onmouseout += "wgrowhighlight(this,'','');";
                }
            }

            #region Client Row Events

            if (!string.IsNullOrEmpty(grid.OnClientRowClick))
            {
                ClientRowEventArgs ea = new ClientRowEventArgs
                                            {
                                                RowIndex = row.RowIndex,
                                                ClientEventType = ClientEventType.OnClientRowClick
                                            };

                string content = JavaScriptConvert.SerializeObject(ea);
                writer.Grid.JsOnData.AppendLine();
                string jsonId = string.Format("{0}r{1}rowclick", grid.ID, row.RowIndex).Replace("-", "A");

                grid.JsOnData.AppendFormat("{0} = {1}", jsonId, content);

                js.AppendFormat(@" onclick=""{0}(this,{1});return false"" ", grid.OnClientRowClick, jsonId);
            }
            if (!string.IsNullOrEmpty(grid.OnClientRowDblClick))
            {
                ClientRowEventArgs ea = new ClientRowEventArgs
                                            {
                                                RowIndex = row.RowIndex,
                                                ClientEventType = ClientEventType.OnClientRowDblClick
                                            };

                string content = JavaScriptConvert.SerializeObject(ea);
                writer.Grid.JsOnData.AppendLine();
                string jsonId = string.Format("{0}r{1}rowdblclick", grid.ID, row.RowIndex).Replace("-", "A");

                grid.JsOnData.AppendFormat("{0} = {1}", jsonId, content);

                js.AppendFormat(@" ondblclick=""{0}(this,{1});return false"" ", grid.OnClientRowDblClick, jsonId);
            }
            if (!string.IsNullOrEmpty(grid.OnClientRowMouseOut))
            {
                ClientRowEventArgs ea = new ClientRowEventArgs
                                            {
                                                RowIndex = row.RowIndex,
                                                ClientEventType = ClientEventType.OnClientRowMouseOut
                                            };

                string content = JavaScriptConvert.SerializeObject(ea);
                writer.Grid.JsOnData.AppendLine();
                string jsonId = string.Format("{0}r{1}rowmouseout", grid.ID, row.RowIndex).Replace("-", "A");

                grid.JsOnData.AppendFormat("{0} = {1}", jsonId, content);

                onmouseout += string.Format(@"{0}(this,{1}); ", grid.OnClientRowMouseOut, jsonId);
            }
            if (!string.IsNullOrEmpty(grid.OnClientRowMouseOver))
            {
                ClientRowEventArgs ea = new ClientRowEventArgs
                                            {
                                                RowIndex = row.RowIndex,
                                                ClientEventType = ClientEventType.OnClientRowMouseOver
                                            };

                string content = JavaScriptConvert.SerializeObject(ea);
                writer.Grid.JsOnData.AppendLine();
                string jsonId = string.Format("{0}r{1}rowmouseout", grid.ID, row.RowIndex).Replace("-", "A");

                grid.JsOnData.AppendFormat("{0} = {1}", jsonId, content);

                onmouseover += string.Format(@"{0}(this,{1}); ", grid.OnClientRowMouseOver, jsonId);

            }

            if (!string.IsNullOrEmpty(onmouseover))
                js.AppendFormat(@" onmouseover=""{0}""", onmouseover);
            if (!string.IsNullOrEmpty(onmouseout))
                js.AppendFormat(@" onmouseout=""{0}""", onmouseout);

            #endregion

            if (row.PreRowHtml != null)
                if (row.PreRowHtml is string)
                    writer.Write((string) row.PreRowHtml);
                else if (row.PreRowHtml is Control)
                    writer.Write((Control) row.PreRowHtml);

            if (grid.RecordsPerRow > 1)
            {
                grid.m_RowsAdded++;

                writer.Write("<tr class=\"wgrow\" id=\"{0}r{1}\" {2} class=\"{3} {4}\">", row.m_Table.m_Grid.ID,
                             grid.m_RowsAdded, js.ToString(), style, row.CssClass);
            }
            else
                writer.Write("<tr class=\"wgrow\" id=\"{0}r{1}\" {2} class=\"{3} {4}\">", row.m_Table.m_Grid.ID,
                             row.RowIndex, js.ToString(), style, row.CssClass);
        }
コード例 #2
0
ファイル: Rendering.cs プロジェクト: yuva2achieve/WebGrid
        private static void StartNewRow(Row row, string style, WebGridHtmlWriter writer)
        {
            Grid          grid        = row.m_Table.m_Grid;
            StringBuilder js          = new StringBuilder(string.Empty);
            string        onmouseover = string.Empty;
            string        onmouseout  = string.Empty;

            if (grid.RowHighLight != Color.Empty)
            {
                row.RowHighLight = grid.RowHighLight;

                if (row.RowHighLight != Color.Empty)
                {
                    onmouseover += string.Format("wgrowhighlight(this, 'over', '{0}');", Grid.ColorToHtml(grid.RowHighLight));
                    onmouseout  += "wgrowhighlight(this,'','');";
                }
            }

            #region Client Row Events

            if (!string.IsNullOrEmpty(grid.OnClientRowClick))
            {
                ClientRowEventArgs ea = new ClientRowEventArgs
                {
                    RowIndex        = row.RowIndex,
                    ClientEventType = ClientEventType.OnClientRowClick
                };

                string content = JavaScriptConvert.SerializeObject(ea);
                writer.Grid.JsOnData.AppendLine();
                string jsonId = string.Format("{0}r{1}rowclick", grid.ID, row.RowIndex).Replace("-", "A");

                grid.JsOnData.AppendFormat("{0} = {1}", jsonId, content);

                js.AppendFormat(@" onclick=""{0}(this,{1});return false"" ", grid.OnClientRowClick, jsonId);
            }
            if (!string.IsNullOrEmpty(grid.OnClientRowDblClick))
            {
                ClientRowEventArgs ea = new ClientRowEventArgs
                {
                    RowIndex        = row.RowIndex,
                    ClientEventType = ClientEventType.OnClientRowDblClick
                };

                string content = JavaScriptConvert.SerializeObject(ea);
                writer.Grid.JsOnData.AppendLine();
                string jsonId = string.Format("{0}r{1}rowdblclick", grid.ID, row.RowIndex).Replace("-", "A");

                grid.JsOnData.AppendFormat("{0} = {1}", jsonId, content);

                js.AppendFormat(@" ondblclick=""{0}(this,{1});return false"" ", grid.OnClientRowDblClick, jsonId);
            }
            if (!string.IsNullOrEmpty(grid.OnClientRowMouseOut))
            {
                ClientRowEventArgs ea = new ClientRowEventArgs
                {
                    RowIndex        = row.RowIndex,
                    ClientEventType = ClientEventType.OnClientRowMouseOut
                };

                string content = JavaScriptConvert.SerializeObject(ea);
                writer.Grid.JsOnData.AppendLine();
                string jsonId = string.Format("{0}r{1}rowmouseout", grid.ID, row.RowIndex).Replace("-", "A");

                grid.JsOnData.AppendFormat("{0} = {1}", jsonId, content);

                onmouseout += string.Format(@"{0}(this,{1}); ", grid.OnClientRowMouseOut, jsonId);
            }
            if (!string.IsNullOrEmpty(grid.OnClientRowMouseOver))
            {
                ClientRowEventArgs ea = new ClientRowEventArgs
                {
                    RowIndex        = row.RowIndex,
                    ClientEventType = ClientEventType.OnClientRowMouseOver
                };

                string content = JavaScriptConvert.SerializeObject(ea);
                writer.Grid.JsOnData.AppendLine();
                string jsonId = string.Format("{0}r{1}rowmouseout", grid.ID, row.RowIndex).Replace("-", "A");

                grid.JsOnData.AppendFormat("{0} = {1}", jsonId, content);

                onmouseover += string.Format(@"{0}(this,{1}); ", grid.OnClientRowMouseOver, jsonId);
            }

            if (!string.IsNullOrEmpty(onmouseover))
            {
                js.AppendFormat(@" onmouseover=""{0}""", onmouseover);
            }
            if (!string.IsNullOrEmpty(onmouseout))
            {
                js.AppendFormat(@" onmouseout=""{0}""", onmouseout);
            }

            #endregion

            if (row.PreRowHtml != null)
            {
                if (row.PreRowHtml is string)
                {
                    writer.Write((string)row.PreRowHtml);
                }
                else if (row.PreRowHtml is Control)
                {
                    writer.Write((Control)row.PreRowHtml);
                }
            }

            if (grid.RecordsPerRow > 1)
            {
                grid.m_RowsAdded++;

                writer.Write("<tr class=\"wgrow\" id=\"{0}r{1}\" {2} class=\"{3} {4}\">", row.m_Table.m_Grid.ID,
                             grid.m_RowsAdded, js.ToString(), style, row.CssClass);
            }
            else
            {
                writer.Write("<tr class=\"wgrow\" id=\"{0}r{1}\" {2} class=\"{3} {4}\">", row.m_Table.m_Grid.ID,
                             row.RowIndex, js.ToString(), style, row.CssClass);
            }
        }