SL4 |域数据源/数据网格 |添加空白行以插入新项目
我正在尝试将 DataForm 和 DataGrid 绑定到 DomainDataSource 并实现添加、删除和编辑项目的功能。
DataForm 部分的一切都运行良好。但是我如何使用 DataGrid 添加新记录呢? 据我所知,到目前为止,有两个工作选项:
向 DataView 添加一个新的“空白”项。
- 问题:由于关键要求和限制,我遇到了验证错误。
使用 Silverlight 4 服务版本(2010 年 9 月)中的“SDK 功能在 DataGrid 控件中启用添加新行功能”
- 问题:究竟发生了什么变化?没有新成员或文档。
以下是一些与我的项目最重要部分相匹配的基本标记声明:
<Grid x:Name="LayoutRoot">
<sdk:DataGrid x:Name="ParentGrid" AutoGenerateColumns="False" ItemsSource="{Binding ElementName=parentDomainDataSource, Path=Data}"/>
<toolkit:DataForm x:Name="ParentForm" CommandButtonsVisibility="All" Grid.Row="1" ItemsSource="{Binding ElementName=parentDomainDataSource, Path=Data}"/>
<sdk:DataGrid x:Name="ChildGrid" Grid.Column="1" AutoGenerateColumns="False" ItemsSource="{Binding ElementName=childDomainDataSource, Path=Data}"/>
<toolkit:DataForm x:Name="ChildForm" CommandButtonsVisibility="All" ItemsSource="{Binding ElementName=childDomainDataSource, Path=Data}"/>
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my1:Child, CreateList=true}" Name="childDomainDataSource" QueryName="GetChildrenQuery"
DomainContext="{StaticResource domainCtx}"/>
</riaControls:DomainDataSource>
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my1:Parent, CreateList=true}" Name="parentDomainDataSource" QueryName="GetParentsQuery"
DomainContext="{StaticResource domainCtx}"/>
</Grid>
不幸的是,我的时间不多了。
预先感谢您的任何帮助。来自德国的最诚挚的问候。希望任何人都可以提供帮助;)
I'm trying to bind a DataForm and DataGrid to a DomainDataSource and implement the functionality of adding, deleting and editing items.
Everything works very well for the DataForm part. But how I'm able to add a new record using the DataGrid?
Like I know until now, there are two working options:
Add a new - "blank" - item to the DataView.
- Problem: I'm getting validatoin errors as a result of key requirements and constraints.
Using the "SDK feature to enable Add New Row capabilities in DataGrid control" from Silverlight 4 service release (September 2010)
- Problem: What exactly has changed? There are no new members or a documentation.
Here are some basic markup declarations matching the most important parts of my project:
<Grid x:Name="LayoutRoot">
<sdk:DataGrid x:Name="ParentGrid" AutoGenerateColumns="False" ItemsSource="{Binding ElementName=parentDomainDataSource, Path=Data}"/>
<toolkit:DataForm x:Name="ParentForm" CommandButtonsVisibility="All" Grid.Row="1" ItemsSource="{Binding ElementName=parentDomainDataSource, Path=Data}"/>
<sdk:DataGrid x:Name="ChildGrid" Grid.Column="1" AutoGenerateColumns="False" ItemsSource="{Binding ElementName=childDomainDataSource, Path=Data}"/>
<toolkit:DataForm x:Name="ChildForm" CommandButtonsVisibility="All" ItemsSource="{Binding ElementName=childDomainDataSource, Path=Data}"/>
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my1:Child, CreateList=true}" Name="childDomainDataSource" QueryName="GetChildrenQuery"
DomainContext="{StaticResource domainCtx}"/>
</riaControls:DomainDataSource>
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my1:Parent, CreateList=true}" Name="parentDomainDataSource" QueryName="GetParentsQuery"
DomainContext="{StaticResource domainCtx}"/>
</Grid>
Unfortunately, I'm running out of time.
Thanks in advance for any help. Best regards from Germany. Hope anybody can help ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚遇到这个问题试图找出类似的事情。在这里发帖是希望这可以节省其他人的时间:
在“新记录”
Button's Click
的代码隐藏中:DataGrid
立即选取新记录并您仍然可以在 DDS 上执行SubmitChangesCommand
将新条目发布回数据库。I just ran into this question trying to figure out similar thing. Posting here in the hope that this saves somebody else the time:
In the code-behind for a "New Record"
Button's Click
:The
DataGrid
picks up the new record instantly and you can still doSubmitChangesCommand
on DDS to post the new entry back to DB.尽管它并没有严格回答您的问题,但使用 PagedCollectionView 效果相当好。此外,您可以按 Esc 键取消正在插入的行。
缺点是你必须做一些簿记工作。
Although it doesn't strictly answer your question, using a PagedCollectionView works rather nicely. In addition, you can hit Esc to cancel the row being inserted.
The downside is you have to do a little bit of book-keeping.