Ingragistic XamGrid:新记录不可编辑

发布于 2024-12-09 03:22:22 字数 501 浏览 4 评论 0 原文

鉴于,

    <igDP:XamDataGrid Name="dataGrid" 
                          DataSource="{Binding RecordList}">
            <igDP:XamDataGrid.FieldLayoutSettings >
                <igDP:FieldLayoutSettings AllowAddNew="true" AddNewRecordLocation="OnTopFixed"/>
            </igDP:XamDataGrid.FieldLayoutSettings>

运行时,我可以在网格顶部看到一个空的新行。但是新行中的所有列都不可编辑!当我将每个字段标记为可编辑时,这些列是可编辑的。

是否可以在“不”明确将每个字段标记为可编辑的情况下让添加记录功能正常工作?

感谢您的关注。

Given,

    <igDP:XamDataGrid Name="dataGrid" 
                          DataSource="{Binding RecordList}">
            <igDP:XamDataGrid.FieldLayoutSettings >
                <igDP:FieldLayoutSettings AllowAddNew="true" AddNewRecordLocation="OnTopFixed"/>
            </igDP:XamDataGrid.FieldLayoutSettings>

On running, I can see a empty new row on top of the grid. But none of the columns in the new row are editable !!! The columns are editable when I mark each of the Fields as editable.

Is it possible to have the add record functionality work while "without" explicitly marking each of the fields as editable ?

Thanks for your interest.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

后来的我们 2024-12-16 03:22:22

你最好的选择是在 infragistics netadvantage 论坛上问这个问题,但是话虽如此...

据我了解,你想要的是一个只读数据网格(其单元格不可编辑),有一个可编辑行来添加新项目...

  1. XamDatagrid.Resources 下添加一个针对 StyleCellValuePresenter
  2. 这将检查给定的单元格值呈现器是否获得焦点并表示添加新行。
  3. 如果是这样,它将通过一些附加行为使父字段可编辑。

    
        
            
    

附加行为如下......

public class CellValuePresenterBehavior
{
    public static DependencyProperty AllowFieldEditProperty
        = DependencyProperty.RegisterAttached(
            "AllowFieldEdit",
            typeof(bool),
            typeof(CellValuePresenterBehavior),
            new PropertyMetadata(false, OnAllowFieldEditChanged));

    private static void OnAllowFieldEditChanged(
        DependencyObject depObj,
        DependencyPropertyChangedEventArgs args)
    {
        var cvp = depObj as CellValuePresenter;
        if (cvp != null)
        {
            cvp.Field.Settings.AllowEdit = (bool)args.NewValue;
        }
    }

    public static bool GetAllowFieldEdit(DependencyObject depObj)
    {
        return (bool) depObj.GetValue(AllowFieldEditProperty);
    }

    public static void SetAllowFieldEdit(DependencyObject depObj, bool value)
    {
        depObj.SetValue(AllowFieldEditProperty, value);
    }
}

希望这有帮助。

You best bet would be asking this on the infragistics netadvantage forum, but having said that...

As I understand what you want is a readonly datagrid (non-editable on its cells) to have a editable row to add new item...

  1. Add a CellValuePresenter targetted Style under XamDatagrid.Resources.
  2. This will check if the given cell value presenter is focused and represents the add new row.
  3. If so it will make the parent field editable via some attached behavior.

    <igDP:XamDataGrid Grid.Row="1"
                      DataSource="{Binding}"
                      AutoFit="True">
        <igDP:XamDataGrid.Resources>
            <Style TargetType="{x:Type igDP:CellValuePresenter}">
                <Style.Triggers>
                    <MultiDataTrigger>                           
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding IsFocused,
                                       RelativeSource={RelativeSource Self}}"
                                       Value="True"/>
                            <Condition Binding="{Binding Record.IsAddRecord,
                                       RelativeSource={RelativeSource Self}}"
                                       Value="True"/>
                        </MultiDataTrigger.Conditions>
                        <Setter 
                            Property="local:CellValuePresenterBehavior.AllowFieldEdit"
                            Value="True"/>
                    </MultiDataTrigger>
                </Style.Triggers>
            </Style>
        </igDP:XamDataGrid.Resources>
        <igDP:XamDataGrid.FieldLayouts>
            <igDP:FieldLayout>
                <!-- Only show the first 4 fields to keep the display simple -->
                <igDP:Field Name="Key" Visibility="Visible">                        
                    <igDP:Field.Settings>
                        <igDP:FieldSettings
                                 EditAsType="{x:Type System:String}"
                            EditorType="{x:Type Editors:XamTextEditor}" 
                                 AllowEdit="False"/>
                    </igDP:Field.Settings>
                </igDP:Field>
                <igDP:Field Name="Value" Visibility="Visible">
                    <igDP:Field.Settings>
                        <igDP:FieldSettings
                                 EditAsType="{x:Type System:String}"
                            EditorType="{x:Type Editors:XamTextEditor}" 
                                 AllowEdit="False"/>
                    </igDP:Field.Settings>
                </igDP:Field>
            </igDP:FieldLayout>
        </igDP:XamDataGrid.FieldLayouts>
        <igDP:XamDataGrid.FieldLayoutSettings>
            <igDP:FieldLayoutSettings AutoGenerateFields="False"
                                      AllowAddNew="True"
                                      AddNewRecordLocation="OnTopFixed"
                                      HighlightAlternateRecords="True"/>
        </igDP:XamDataGrid.FieldLayoutSettings>
    </igDP:XamDataGrid>
    

And the attached behavior is as below...

public class CellValuePresenterBehavior
{
    public static DependencyProperty AllowFieldEditProperty
        = DependencyProperty.RegisterAttached(
            "AllowFieldEdit",
            typeof(bool),
            typeof(CellValuePresenterBehavior),
            new PropertyMetadata(false, OnAllowFieldEditChanged));

    private static void OnAllowFieldEditChanged(
        DependencyObject depObj,
        DependencyPropertyChangedEventArgs args)
    {
        var cvp = depObj as CellValuePresenter;
        if (cvp != null)
        {
            cvp.Field.Settings.AllowEdit = (bool)args.NewValue;
        }
    }

    public static bool GetAllowFieldEdit(DependencyObject depObj)
    {
        return (bool) depObj.GetValue(AllowFieldEditProperty);
    }

    public static void SetAllowFieldEdit(DependencyObject depObj, bool value)
    {
        depObj.SetValue(AllowFieldEditProperty, value);
    }
}

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文