标签: nested

嵌套的BeginCollectionItem

我正在使用Steve Sanderson的BeginCollectionItem方法来添加动态内容.当我在第一级做它时,一切正常.但是,当尝试实现嵌套集合意味着另一个BeginCollectionItem中的BeginCollectionItem时,它似乎不起作用.

我的模型如下:

public class Order
{

        [Key]
        [HiddenInput]
        public int id { get; set; }

        [Display(Name = "Order number")]
        public string number { get; set; }

        ...

        [Display(Name = "Payment method")]
        public List<PaymentMethod> payment_methods { get; set; }

        ...
}

public class PaymentMethod
{
        public MethodOfPayment method { get; set; }
        public CC cc { get; set; }
        public CASH cash { get; set; }
        public TT tt { get; set; }
}

public class TT
{
        [Key]
        public …
Run Code Online (Sandbox Code Playgroud)

nested partial dynamically-generated asp.net-mvc-3

11
推荐指数
1
解决办法
9365
查看次数

t-sql WITH WITH

我必须在WITH查询上进行查询,例如

; WITH #table1  
(  
SELECT id, x from ... WHERE....  
UNION ALL  
 SELECT id, x from ... WHERE...  
)  

WITH #table2  
(  
 SELECT DISTINCT tbl_x.*,ROW_NUMBER() OVER (order by id) as RowNumber  
WHERE id in ( SELECT id from #table1)  
)  

SELECT * FROM #table2 WHERE RowNumber > ... and ...
Run Code Online (Sandbox Code Playgroud)

所以我必须在WITH上使用WITH,然后在第二个WITH上使用SELECT,我该怎么做?

t-sql select nested

11
推荐指数
1
解决办法
2万
查看次数

WPF ControlTemplate打破了风格

有效的东西

我需要设置某种类型的控件的样式,这些控件是StackPanel的子代.我正在使用:

<StackPanel>
    <StackPanel.Resources>
        <Style TargetType="{x:Type TextBlock}">...</Style>
    </StackPanel.Resources>
    <TextBlock ...>
    ...
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

这很好用!每个TextBlock都会查看它的父级(StackPanel)的资源,以了解它应该如何设置样式.将TextBlock嵌套到StackPanel上的距离无关紧要...如果它在其直接父级中找不到样式,它将查看其父级的父级,依此类推,直到找到某些东西(在这种情况下) ,中所定义的风格).

那些不起作用的东西

当我在ContentControl中嵌套TextBlock时遇到问题,ContentControl有一个模板(参见下面的代码).ControlTemplate似乎破坏了TextBlock从其父母,祖父母那里检索其风格的方式......

有效地使用ControlTemplate似乎可以解决TextBlock找到其合法风格的方法(StackPanel.Resources中的风格).遇到ControlTemplate时,它会停止在树上的资源中查找其样式,而是默认使用Application本身的MergedDictionaries中的样式.

<StackPanel Orientation="Vertical" Background="LightGray">
    <StackPanel.Resources>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Foreground" Value="Green" />
        </Style>
    </StackPanel.Resources>

    <TextBlock Text="plain and simple in stackpanel, green" />
    <ContentControl>
        <TextBlock Text="inside ContentControl, still green" />
    </ContentControl>
    <ContentControl>
        <ContentControl.Template>
            <ControlTemplate TargetType="{x:Type ContentControl}">
                <StackPanel Orientation="Vertical">
                    <ContentPresenter />
                    <TextBlock Text="how come this one - placed in the template - is not green?" />
                </StackPanel>
            </ControlTemplate>
        </ContentControl.Template>
        <TextBlock Text="inside ContentControl with a template, this …
Run Code Online (Sandbox Code Playgroud)

wpf xaml nested controltemplate

11
推荐指数
1
解决办法
3805
查看次数

用嵌套枚举包装结构 - 在向量模板中引用

这是我在一天半前在cython用户组中提出的一个问题交叉帖子,但还没有得到任何回复,所以我在一个更一般的论坛上试试我的运气

我一直在尝试用以下方法来包装以下代码,并且存在各种程度的错误.大量的搜索使我绊倒了类似的问题,也是一张出色的心愿单,但说实话,我不确定我是否在正确的道路上.

plow_types.h:

namespace Plow {

    struct JobState {
      enum type {
        INITIALIZE = 0,
        RUNNING = 1,
        FINISHED = 2
      };
    };
    ...
    class JobFilterT {
     public:
      ...
      std::vector<JobState::type>  states;
      ...
Run Code Online (Sandbox Code Playgroud)

所以我试图包装这个Plow::JobState::type枚举.在找到另一个类似的帖子后,我得到的最接近的结果就是这次尝试:

plow_types.pxd:

cdef extern from "rpc/plow_types.h" namespace "Plow":

    enum JobState_type "Plow::JobState::type":
        INITIALIZE "Plow::JobState::INITIALIZE"
        RUNNING "Plow::JobState::RUNNING"
        FINISHED "Plow::JobState::FINISHED"

    struct JobState:
        JobState_type type
    ...
    cdef cppclass JobFilterT:
        vector[JobState_type] states 
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:

src/plow.cpp: In function ‘std::vector<Plow::JobState::type, std::allocator<Plow::JobState::type> > __pyx_convert_vector_from_py_enum__Plow_3a__3a_JobState_3a__3a_type(PyObject*)’:
src/plow.cpp:6688: error: invalid conversion from …
Run Code Online (Sandbox Code Playgroud)

c++ python enums nested cython

11
推荐指数
1
解决办法
1599
查看次数

是否可以在 Vue.js 中嵌套方法以对相关方法进行分组?

我想将我的一些 Vue.js 方法组合在一种“子方法”类中,但我似乎只能拥有单级方法。

例如,如果我想要一组纯粹处理按钮操作的方法:

new Vue({

    el: '#app',

    data: { },

    methods: {

        buttonHandlers: {

            handler1: function() {
                dosomething;
            },

            handler2: function() {
                dosomething;
            }

        }

    }

});
Run Code Online (Sandbox Code Playgroud)

我希望能够然后使用类似的东西:

<button v-on:click="buttonHandlers.handler1">Click Me</button>
Run Code Online (Sandbox Code Playgroud)

但什么也没有发生。

已经试过迫使功能加入括号运行:

<button v-on:click="buttonHandlers.handler1()">Click Me</button>
Run Code Online (Sandbox Code Playgroud)

但我收到此控制台错误:

未捕获的类型错误:scope.buttonHandlers.handler1 不是函数

我已经设置了一个小的https://jsfiddle.net/ozx9oc4c/来演示我的意思。

如果有人知道在 Vue.js 中对父方法下的函数进行逻辑分组的方法,而不是没有真正结构的单级方法的页面和页面,我会很感激你的知识。

javascript methods nested namespaces vue.js

11
推荐指数
3
解决办法
5455
查看次数

仍在评估废弃分支中的嵌套constexpr-if语句?

在我看来,在MSVC(版本15.7.3)中评估另一个constexpr-if语句的废弃分支内的constexpr-if语句.

请考虑以下代码:

#include <tuple>
#include <type_traits>

template <size_t I>
int test() {
    if constexpr(I != 0) {
        return 0;
    }
    else { // This branch is discarded, but it seems that the constexpr-if below is still evaulated?
        if constexpr(std::is_same_v<int, std::tuple_element_t<I, std::tuple<int>>>) { // some constexpr check that is valid only when I == 0
            return 1;
        }
        else {
            return 2;
        }
    }
}

int main() {
    test<1>();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

上面的代码无法在MSVC中编译,因为std::tuple_element_tI超过元组的边界时,静态断言将失败.这表明,不管怎样,废弃分支中的代码也会被评估,即使它依赖于模板参数I.

根据cppreference …

c++ nested c++17 if-constexpr

11
推荐指数
1
解决办法
521
查看次数

如何在数据库中创建嵌套类别?

我正在制作一个视频网站,其中的类别将被嵌套:

例如编程 - > C语言 - > MIT视频 - >视频1编程 - > C语言 - >斯坦福视频 - >视频1编程 - > Python - >视频1

这些类别和子类别将由用户即时创建.当人们以可导航菜单的形式创建它们时,我将需要显示它们,以便人们可以轻松浏览该集合.

有人可以帮助我如何创建这样的数据库吗?

database nested categories

10
推荐指数
4
解决办法
2万
查看次数

Java嵌套通配符泛型将无法编译

我在Java泛型中遇到了有界嵌套通配符的问题.

这是一个常见的案例:

public void doSomething(Set<? extends Number> set) {}

public void callDoSomething() {
    Set<Integer> set = new HashSet<Integer>();
    doSomething(set);
}
Run Code Online (Sandbox Code Playgroud)

这是标准的Java泛型,工作正常.

但是,如果通配符变为嵌套,则它不再起作用:

public void doSomething(Map<String, Set<? extends Number>> map) {}

public void callDoSomething() {
    Map<String, Set<Integer>> map = new HashMap<String, Set<Integer>>();
    doSomething(map);
}
Run Code Online (Sandbox Code Playgroud)

这会导致编译器错误.

我尝试了各种演员表和通配符排列,但我无法使其正常工作.我不记得以前看过这个问题了,多年来我一直在使用仿制药.我是否太累了,错过了一些明显的东西?

java generics nested wildcard

10
推荐指数
1
解决办法
1226
查看次数

嵌套的@ Html.DisplayFor(model => baseClass,"BaseClass"),用于不渲染基类模板

几个子类(例如,Cheese)共享从基类(Product)派生的公共属性,其属性如SKU,NameDescription.

为了避免在渲染显示/编辑器模板时出现重复,我希望每个子类模板(Cheese.cshtml)在其共享公共基类模板(Product.cshtml)下面呈现其唯一字段.

但是,从派生类转换到基类(Product)cheese并尝试在子类模板中显示其模板无效.

DisplayTemplate文件结构:

.\Views\Shared\DisplayTemplates
    .\Product.cshtml -- renders common base class fields
    .\Cheese.cshtml -- renders unique class fields and calls Product.cshtml
Run Code Online (Sandbox Code Playgroud)

Cheese.chtml:

@model Application.Data.Models.Cheese

@{
    var product = (Application.Data.Models.Part)Model;
}

Base Product Fields:
@Html.DisplayFor(x => products, "Product") @* no effect! *@

<div class="field">
    <div class="display-label">@Html.LabelFor(m => Model.UniqueProperty)</div>
    <div class="display-field">@Html.DisplayFor(m => Model.UniqueProperty)</div>
</div>
Run Code Online (Sandbox Code Playgroud)

转换为基类并呈现Product.cshtml模板可以从View中正常工作,但不能在子类模板中工作.

如何从子类模板中为我的基类渲染公共模板?

templates nested razor asp.net-mvc-3

10
推荐指数
1
解决办法
5132
查看次数

ie11与嵌套的showModalDialog有关

我正在使用一个Web应用程序,它使用许多模态对话框来获取输入.当我开始使应用程序与IE11兼容时,问题就开始了(它在IE8中运行得非常好).当从主页调用时,模态对话框完美地返回值,但是当我从模态对话框创建模态对话框时,返回值但未被捕获并被视为undefined.

//calling the values
var ret = ShowDialogOpen(pageUrl, width, height);

function ShowDialogOpen(PageName, strWidth, strHeight) {
    var DialogOptions = "Center=Yes; Scrollbar=No; dialogWidth=" + strWidth + ";          dialogTop=150px; dialogHeight=" + strHeight + "; Help=No; Status=No; Resizable=Yes;";
    var OpenUrl = PageName; 
    var ret = window.showModalDialog(OpenUrl, "Yes", DialogOptions);
		    
    return ret;
}

//Dialog returning values
function ReturnValues() {
    var lstBox = document.getElementById("lst_Name");
    var texts = "";
    var values = "";
    for (i=0; i<lstBox.options.length; i++) {
        texts = texts + lstBox.options[i].text + "!";
        values …
Run Code Online (Sandbox Code Playgroud)

javascript nested showmodaldialog internet-explorer-8 internet-explorer-11

10
推荐指数
1
解决办法
5322
查看次数