问题标签 [nested-properties]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
1869 浏览

c# - 如何使用 FastMember 设置嵌套属性值

当我尝试使用 FastMember 设置嵌套成员属性时出现异常。例如,当有这些课程时

我想将First.Second一个实例设置为"hello".

我无法将其拆分为 ["First"]["Second"],因为此时我不知道深度。嵌套属性是否有神奇的访问权限,还是我必须自己拆分层次结构?

0 投票
1 回答
532 浏览

angular - Angular2 英雄之旅 - Hero.ts 属性和嵌套对象

我正在学习 Angular2 Tour of Heroes 教程,并且正在尝试学习如何使用服务。我能够让基本教程开始工作,但是当我尝试变得更复杂一点时,我的应用程序崩溃了,我不确定我做错了什么。

可以正常工作的基本模型由一个模拟英雄对象和一个指定每行类型的 hero.ts 文件组成。

这是我指的英雄之旅教程: https ://angular.io/docs/ts/latest/tutorial/toh-pt4.html

hero.ts 文件:

模拟英雄.ts 文件:

如果我想添加嵌套对象,例如帐户,我会收到错误消息:

对象字面量只能指定已知属性,而“Hero”类型中不存在“帐户”。

hero.ts 文件:

模拟英雄.ts 文件:

所以,我知道我需要识别“帐户”,但我错过了我对“帐户”进行分类的内容,以便可以正确嵌套对象。

提前致谢。

0 投票
1 回答
1108 浏览

javafx - 如果嵌套对象绑定更改,如何更新 JavaFX TableView?

我有一个ObservableList<Member>要显示在TableView<Member>.

该类Member由 a Person(和其他不重要的值组成,因为它们不会出现在 tableview 中)。每个Person人都有一个StringProperty“名字”和一个ObjectProperty<Dog>“狗”。每只狗都有一个StringProperty“名字”。

tableview 应该在第一列显示人的名字,在第二列显示狗的名字。像这样:示例表视图

我设法通过绑定TableColumn<Member, Person>member.personProperty()自定义单元工厂并使用自定义单元工厂来显示人名或狗名来实现这一点。

现在,我还必须ComboBoxes 通过它用户能够更新TableView. valueProperty()因此,我在所选项目和组合框之间创建了绑定。

如果表格视图通过组合框更改人名的单元格,则会更新该单元格,而狗名的单元格不会自动显示新值。我知道这是因为Member没有收到有关狗属性更改的通知。但是我还没有找到一个解决方案,如何让一个对象知道它的子对象中的变化。

所以我想,总而言之,我的问题是(1)如何在平面表视图中显示嵌套对象,以及(2)如果任何(可能)嵌套属性发生变化,如何自动更新表视图。

示例代码:

0 投票
1 回答
122 浏览

c# - 设置嵌套属性值的方法

我正在为一个软件编写一个插件,该软件要求所有代码都在一个类(或嵌套类)中......

我想要做的是创建一个方法来处理对_data对象嵌套属性的更改,并为我提供一个中心位置来执行诸如设置脏标志之类的操作,以便我知道以后保存它。

下面是一些说明我的文件结构的代码,底部是两个伪方法,希望可以让您了解我要完成的工作。

0 投票
1 回答
290 浏览

android - 您可以在 XML 布局文件中将视图设置为另一个视图的属性吗?

我们有一个GridView具有headerViewfooterView属性的自定义。我想知道在 Android 中是否可以从布局文件中设置这些属性。

Windows 中的 XAML 让您可以轻松地做到这一点,因为您可以通过属性(例如字符串、数字或其他简单类型)或使用ControlType:PropertyName语法通过嵌套元素(对于任何对象类型)来指定属性。

如果 Android 支持类似的东西,这是一个伪版本:

显然,上面的说法是不成立的。但是有可能在 Android 中做类似的事情,还是我必须在 Activity/Fragment 的代码隐藏中做?

0 投票
1 回答
44 浏览

java - Vaadin8 网格嵌套属性错误

我正在尝试创建一个带有嵌套属性的网格。但我找不到在网格列中显示嵌套属性字段的方法。

我只想在网格中显示 user.username。但在此代码中,显示所有用户对象堆栈引用或其他。

像这样:com.meyrasoft.checkupbox.model.User@12703bc

0 投票
1 回答
133 浏览

java - 嵌套属性值上的 Collections.sort()

我正在研究数据表的排序功能。我有 JSF Web 控制器:

在这个控制器中,我有一个排序方法:

在页面视图上调用排序后,它会抛出NullPointerException. 我认为主要原因是它内部Comparator无法读取clubName获得 Club 对象后应该可以访问的值。有没有可能比较嵌套属性的值?

0 投票
2 回答
76 浏览

javascript - 一种在不知道嵌套 js 对象中的路径的情况下访问属性的方法

有没有办法在不知道其路径的情况下访问对象内的嵌套属性?例如我可以有这样的东西

有没有“提取”className财产的巧妙方法?我有一个解决方案,但它非常难看,它仅适用于这两种情况,我想知道是否有更灵活的方法可以做

0 投票
2 回答
1871 浏览

javascript - JavaScript 嵌套属性

如果我有一个具有嵌套属性的对象。是否有一个函数可以搜索所有属性,以及具有其他对象值的属性(它们也有自己的属性)等等?

示例对象:

在上面的对象中有一种方法我可以简单地调用类似的东西

0 投票
1 回答
281 浏览

c# - C# NestedClass Expanded Property to Refresh/Invalidate Control in Design Mode

I'm trying to reproduce how Font class Nested Property is able to Invalidate() it's containing Control when the values are changed from the Properties window, without a need to lost focus on the form window. Like if you change the Size property, the Form window will be automatically redrawn with a matching Font Size.

The complete code is at the end of this post

  1. The test NestedClass is very simple which has two Properties and uses a custom ExpandableObjectConverter.

  2. The ContainerClass extends Control class. It invokes Control.Invalidate() method when the NestedClass value is changed. Properties of the NestedClass are drawn by overriding Control.OnPaint() method.

Resulting Control when loaded to the Designer : Initial Draw

Changing the values directly from the NestedClass parent property triggers the redraw : Updating from the parent property works

But changing the values from the nested property, does not redraw : Updating from the nested properties doesn't work

If later the Form window is clicked, Invalidate() is triggered : After Form window clicked

Font class does not require extra click in the design window in order to redraw the control. Can we achieve this same behavior with a custom class like this?

For reference I've already looked into :

  1. INotifyPropertyChanged ==> Problem here is that the PropertyChanged event is only subscribed by the container Control when the item is first added. If I close the Form[Design] window and reopens it, the event will not be subscribed again.
  2. RefreshProperties.All or RefreshProperties.Repaint does not seems to do anything.

If all else fails, obviously clicking on the form designer window will solve the problem, but it bugs me that a built-in .NET class can do this, but a custom class cannot. Any suggestions are greatly appreciated.

The Code :