我需要在某些列上创建一个包含多个组的网格,我的代码是
<telerik:RadGrid Skin="MetroTouch" ID="grdQuestionnaire" RenderMode="Lightweight" runat="server"
AllowMultiRowSelection="True" AllowPaging="True" ShowGroupPanel="False"
AutoGenerateColumns="False" GridLines="none"
showchooser="true"
OnItemCommand="grdQuestionnaire_ItemCommand"
OnNeedDataSource="grdQuestionnaire_NeedDataSource"
OnItemDataBound="grdQuestionnaire_ItemDataBound"
OnDetailTableDataBind="grdQuestionnaire_DetailTableDataBind">
<GroupingSettings ShowUnGroupButton="false"></GroupingSettings>
<MasterTableView GroupLoadMode="Client" NoMasterRecordsText="No Question Added" TableLayout="Fixed" DataKeyNames="QuestionId,QuestionCode,LanguageQ">
<DetailTables >
<telerik:GridTableView NoDetailRecordsText="No Options Added" Name="Options" Width="100%">
<Columns>
<telerik:GridBoundColumn SortExpression="OptionDesc" HeaderText="Option" HeaderButtonType="TextButton"
DataField="OptionDesc">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="OptionWeightage" HeaderText="Weightage" HeaderButtonType="TextButton"
DataField="OptionWeightage">
</telerik:GridBoundColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
<GroupByExpressions>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldAlias="WorkshopName" FieldName="WorkshopName" HeaderText="Workshop"></telerik:GridGroupByField>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="WorkshopCode"></telerik:GridGroupByField>
</GroupByFields>
</telerik:GridGroupByExpression>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldAlias="" FieldName="AssessmentType" HeaderText="Type"></telerik:GridGroupByField>
<telerik:GridGroupByField FieldAlias="QuestionnaireDesc" FieldName="QuestionnaireDesc" HeaderText="Description" FormatString=""></telerik:GridGroupByField>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="QuestionnaireCode"></telerik:GridGroupByField>
</GroupByFields>
</telerik:GridGroupByExpression>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldAlias="QuestionCode" FieldName="QuestionCode" HeaderText="Question">
</telerik:GridGroupByField>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="QuestionCode"></telerik:GridGroupByField>
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<Columns>
<telerik:GridBoundColumn DataField="QuestionDesc" HeaderText="Question"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="QuestionWeightage" HeaderText="Weightage"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LanguageQ" HeaderText="Language"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CreatedBy" HeaderText="Created By"></telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Action" UniqueName="colAction">
<HeaderStyle HorizontalAlign="Left" Font-Bold="false" VerticalAlign="NotSet" />
<ItemTemplate>
<asp:LinkButton ID="addOption" CommandName="addNewOption" runat="server" CssClass="btn btn-info">Add Options</asp:LinkButton>
<asp:LinkButton ID="deleteQuestion" CommandName="deletequestion" runat="server" CssClass="btn btn-danger">Delete</asp:LinkButton>
</ItemTemplate>
<HeaderStyle Font-Bold="True" />
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
我有一个场景,我需要显示带有组 的按钮 - 这部分通过订阅事件 OnItemDataBound强>
protected void grdQuestionnaire_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridGroupHeaderItem)
{
GridGroupHeaderItem hi = (GridGroupHeaderItem)e.Item;
DataRowView groupDataRow = (DataRowView)e.Item.DataItem;
DataRowView drv = ((DataRowView)e.Item.DataItem);
string columnname = drv.DataView.Table.Columns[0].ColumnName;
switch (columnname)
{
case "WorkshopName":
{
LinkButton btn = new LinkButton();
btn.Text = "Add workshop";
// btn.OnClientClick = "if (!confirm('Are you sure you all information is correct for this employee?')) return false;";
btn.CssClass = "btn btn-sm btn-info";
btn.Style.Add(HtmlTextWriterStyle.MarginRight, "0px");
btn.CommandName = "AddWorkshop";
TableCell customcell = new TableCell();
customcell.Controls.Add(btn);
hi.Cells.Add(customcell);
hi.Cells[hi.Cells.Count - 2].ColumnSpan = hi.Cells[hi.Cells.Count - 2].ColumnSpan - 1;
break;
}
case "QuestionCode":
{
LinkButton btn = new LinkButton();
btn.Text = "Add question";
btn.CssClass = "btn btn-sm btn-success";
btn.Style.Add(HtmlTextWriterStyle.MarginRight, "0px");
btn.CommandName = "AddQuestion";
TableCell customcell = new TableCell();
customcell.Controls.Add(btn);
hi.Cells.Add(customcell);
hi.Cells[hi.Cells.Count - 2].ColumnSpan = hi.Cells[hi.Cells.Count - 2].ColumnSpan - 1;
break;
}
}
}
}
在扩展时,该表来 self 从以下事件 OnDetailTableDataBind
添加的其他数据表 protected void grdQuestionnaire_DetailTableDataBind(object sender, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
string n = e.DetailTableView.Name;
string QuestionCode = dataItem.GetDataKeyValue("QuestionCode").ToString();
string Language = dataItem.GetDataKeyValue("LanguageQ").ToString();
DataSet ds = clsQuestionnaireDAC.GetOptions(QuestionCode, Language);
e.DetailTableView.DataSource = ds.Tables[0];
}
我不知道为什么当表格展开时会出现问题,我的自定义按钮 神秘地消失并停在网格中。这是展开明细表后的结果
任何人都可以指导我解决这种情况,以防止我的 MasterTableView 像扩展前一样。
最佳答案
通常,在类似的场景中使用模板是一个更好的主意: http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/grouping/group-header-and-footer-templates
例如,如果您有以下定义:
<GroupByExpressions>
<telerik:GridGroupByExpression>
<GroupByFields>
<telerik:GridGroupByField FieldName="ShipCountry" />
</GroupByFields>
<SelectFields>
<telerik:GridGroupByField FieldName="ShipCountry" />
</SelectFields>
</telerik:GridGroupByExpression>
<telerik:GridGroupByExpression>
<GroupByFields>
<telerik:GridGroupByField FieldName="ShipName" />
</GroupByFields>
<SelectFields>
<telerik:GridGroupByField FieldName="ShipName" />
</SelectFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
你可以使用类似这样的东西:
<GroupHeaderTemplate>
<asp:Label runat="server" ID="ShipCountryLabel" Text='<%# "ShipCountry: "+
(((GridGroupHeaderItem)Container).AggregatesValues["ShipCountry"]) %>'
Visible='<%# ((((GridGroupHeaderItem)Container).AggregatesValues["ShipCountry"]) != null) %>'>
</asp:Label>
<asp:Label runat="server" ID="ShipNameLabel" Text='<%# "ShipName: "+
(((GridGroupHeaderItem)Container).AggregatesValues["ShipName"]) %>'
Visible='<%# ((((GridGroupHeaderItem)Container).AggregatesValues["ShipName"]) != null) %>'>
</asp:Label>
<br />
<asp:Button ID="Button2" runat="server" Text="MyButton"
Visible='<%# ((((GridGroupHeaderItem)Container).AggregatesValues["ShipName"]) != null) %>' />
</GroupHeaderTemplate>
这将仅显示内部组级别的按钮。
如果您坚持使用代码隐藏方法,则需要使用 ItemCreated。您可以使用下面演示的方法提取字段名称并在页面生命周期的后期添加控件:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridGroupHeaderItem)
{
GridGroupHeaderItem headerItem = e.Item as GridGroupHeaderItem;
int index = headerItem.GroupIndex.Split('_').Length - 1;
GridGroupByExpression exp = headerItem.OwnerTableView.GroupByExpressions[index] as GridGroupByExpression;
string fieldName = exp.GroupByFields[0].FieldName;
if (fieldName == "ShipName")
{
Button button = new Button()
{
ID = "GroupButton1",
Text = "MyButton"
};
headerItem.Load += (s, a) =>
{
headerItem.DataCell.Controls.Add(new Literal() { Text = headerItem.DataCell.Text });
headerItem.DataCell.Controls.Add(button);
};
}
}
}
我希望这会有所帮助。
关于c# - RadGrid 在细节表扩展时刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37879561/
我正在编写一个包含C扩展的gem。通常当我写一个gem时,我会遵循TDD的过程,我会写一个失败的规范,然后处理代码直到它通过,等等......在“ext/mygem/mygem.c”中我的C扩展和在gemspec的“扩展”中配置的有效extconf.rb,如何运行我的规范并仍然加载我的C扩展?当我更改C代码时,我需要采取哪些步骤来重新编译代码?这可能是个愚蠢的问题,但是从我的gem的开发源代码树中输入“bundleinstall”不会构建任何native扩展。当我手动运行rubyext/mygem/extconf.rb时,我确实得到了一个Makefile(在整个项目的根目录中),然后当
如何在ruby中调用C#dll? 最佳答案 我能想到几种可能性:为您的DLL编写(或找人编写)一个COM包装器,如果它还没有,则使用Ruby的WIN32OLE库来调用它;看看RubyCLR,其中一位作者是JohnLam,他继续在Microsoft从事IronRuby方面的工作。(估计不会再维护了,可能不支持.Net2.0以上的版本);正如其他地方已经提到的,看看使用IronRuby,如果这是您的技术选择。有一个主题是here.请注意,最后一篇文章实际上来自JohnLam(看起来像是2009年3月),他似乎很自在地断言RubyCL
我正在尝试在Ruby中复制Convert.ToBase64String()行为。这是我的C#代码:varsha1=newSHA1CryptoServiceProvider();varpasswordBytes=Encoding.UTF8.GetBytes("password");varpasswordHash=sha1.ComputeHash(passwordBytes);returnConvert.ToBase64String(passwordHash);//returns"W6ph5Mm5Pz8GgiULbPgzG37mj9g="当我在Ruby中尝试同样的事情时,我得到了相同sha
我想这样组织C源代码:+/||___+ext||||___+native_extension||||___+lib||||||___(Sourcefilesarekeptinhere-maycontainsub-folders)||||___native_extension.c||___native_extension.h||___extconf.rb||___+lib||||___(Rubysourcecode)||___Rakefile我无法使此设置与mkmf一起正常工作。native_extension/lib中的文件(包含在native_extension.c中)将被完全忽略。
C#实现简易绘图工具一.引言实验目的:通过制作窗体应用程序(C#画图软件),熟悉基本的窗体设计过程以及控件设计,事件处理等,熟悉使用C#的winform窗体进行绘图的基本步骤,对于面向对象编程有更加深刻的体会.Tutorial任务设计一个具有基本功能的画图软件**·包括简单的新建文件,保存,重新绘图等功能**·实现一些基本图形的绘制,包括铅笔和基本形状等,学习橡皮工具的创建**·设计一个合理舒适的UI界面**注明:你可能需要先了解一些关于winform窗体应用程序绘图的基本知识,以及关于GDI+类和结构的知识二.实验环境Windows系统下的visualstudio2017C#窗体应用程序三.
我有一个要在我的Rails3项目中使用的数组扩展方法。它应该住在哪里?我有一个应用程序/类,我最初把它放在(array_extensions.rb)中,在我的config/application.rb中我加载路径:config.autoload_paths+=%W(#{Rails.root}/应用程序/类)。但是,当我转到railsconsole时,未加载扩展。是否有一个预定义的位置可以放置我的Rails3扩展方法?或者,一种预先定义的方式来添加它们?我知道Rails有自己的数组扩展方法。我应该将我的添加到active_support/core_ext/array/conversion
我想编写一个ruby脚本来递归复制目录结构,但排除某些文件类型。因此,给定以下目录结构:folder1folder2file1.txtfile2.txtfile3.csfile4.htmlfolder2folder3file4.dll我想复制这个结构,但不包含.txt和.cs文件。因此,生成的目录结构应如下所示:folder1folder2file4.htmlfolder2folder3file4.dll 最佳答案 您可以使用查找模块。这是一个代码片段:require"find"ignored_extensions=[".cs"
这个问题有两个部分。在RubyProgrammingLanguage一书中,有一个使用模块扩展字符串对象和类的示例(第8.1.1节)。第一个问题。为什么如果您使用新方法扩展类,然后创建该类的对象/实例,则无法访问该方法?irb(main):001:0>moduleGreeter;defciao;"Ciao!";end;end=>nilirb(main):002:0>String.extend(Greeter)=>Stringirb(main):003:0>String.ciao=>"Ciao!"irb(main):004:0>x="foobar"=>"foobar"irb(main):
假设我们有A、B、C类。Adefself.inherited(sub)#metaprogramminggoeshere#takeclassthathasjustinheritedclassA#andforfooclassesinjectprepare_foo()as#firstlineofmethodthenrunrestofthecodeenddefprepare_foo#=>prepare_foo()neededhere#somecodeendendBprepare_foo()neededhere#somecodeendend如您所见,我正在尝试将foo_prepare()调用注入
我如何做Ruby方法"Flatten"RubyMethod在C#中。此方法将锯齿状数组展平为一维数组。例如:s=[1,2,3]#=>[1,2,3]t=[4,5,6,[7,8]]#=>[4,5,6,[7,8]]a=[s,t,9,10]#=>[[1,2,3],[4,5,6,[7,8]],9,10]a.flatten#=>[1,2,3,4,5,6,7,8,9,10 最佳答案 递归解决方案:IEnumerableFlatten(IEnumerablearray){foreach(variteminarray){if(itemisIEnume