Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mvvm can';t改变网格';将网格中的数据重新加载到zkoss时的ui_Mvvm_Zk_Zk Grid - Fatal编程技术网

Mvvm can';t改变网格';将网格中的数据重新加载到zkoss时的ui

Mvvm can';t改变网格';将网格中的数据重新加载到zkoss时的ui,mvvm,zk,zk-grid,Mvvm,Zk,Zk Grid,我有一个约会箱 <datebox id="infrom" style ="z-index: 100000;" format="yyyy-MM-dd" value ="@bind(vm.date)" onChange="@global-command('dataChanged', indate = infrom.value)" /> 日期的默认值现在为-1 并进行按钮搜索 <button id="searchButton" label="Search" image

我有一个约会箱

<datebox id="infrom" style ="z-index: 100000;" format="yyyy-MM-dd" value ="@bind(vm.date)"
    onChange="@global-command('dataChanged', indate = infrom.value)" /> 

日期的默认值现在为-1 并进行按钮搜索

<button id="searchButton" label="Search" image="/img/search.png"  onClick="@command('listCars', indate = infrom.value)"/>

网格将加载昨天的数据 当我选择另一天 网格将加载所选日期的数据 这就是我的网格

<listbox id="carListbox" height="" emptyMessage="No data found in the result" model="@bind(vm.cars)" >

    <listhead>
        <listheader label="Date" />
        <listheader label="Actionid" />
        <listheader label="Num user" />
        <listheader label="Total action" />
    </listhead>
    <template name="model" >
        <listitem>
            <listcell label="@bind(each.date)"></listcell>
            <listcell label ="@bind(each.action)"></listcell>
            <listcell label="@bind(each.user)"></listcell>
            <listcell label="@bind(each.total)"></listcell>
        </listitem>
    </template>
</listbox>

这是我的密码

private List<Car> cars;
public List<Car> getCars()
{

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Calendar c = Calendar.getInstance();
    c.setTime(new Date()); // Now use today date.
    c.add(Calendar.DATE, -1); 
    String output = sdf.format(c.getTime());
    final StringBuilder builder = new StringBuilder("");
    for (final Action action : getActions()) {
        if (action.getChecked()) {
          builder.append(';');
            builder.append(action.getActionid());
        }
    }
    String lstAction = builder.toString(); 
    lstAction = lstAction.substring(1);
    String[] arrAction = lstAction.split(";");
    cars = carService.search(output, arrAction);

    return cars;
}

    @Command
@NotifyChange("cars")
public void listCars(@BindingParam("indate") Date indate){
SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd");
String date  = dt1.format(indate);
final StringBuilder builder = new StringBuilder("");
for (final Action action : actions) {
    if (action.getChecked()) {
      builder.append(';');
        builder.append(action.getActionid());
    }
}
String lstAction = builder.toString(); 
lstAction = lstAction.substring(1);
String[] arrAction = lstAction.split(";");
cars = carService.search(date, arrAction);
//return result;
//carListbox.setModel(new ListModelList<Car>(result));
}
私家车列表;
公共列表getCars()
{
SimpleDataFormat sdf=新SimpleDataFormat(“yyyy-MM-dd”);
Calendar c=Calendar.getInstance();
c、 setTime(new Date());//现在使用今天日期。
c、 添加(Calendar.DATE,-1);
字符串输出=sdf.format(c.getTime());
最终StringBuilder=新StringBuilder(“”);
对于(最终操作:getActions()){
if(action.getChecked()){
builder.append(“;”);
append(action.getActionid());
}
}
字符串lstAction=builder.toString();
lstAction=lstAction.substring(1);
字符串[]arrAction=lstAction.split(“;”);
cars=carService.search(输出、排列);
返回车辆;
}
@命令
@改变(“汽车”)
公共无效列表车(@BindingParam(“indate”)日期indate){
SimpleDataFormat dt1=新SimpleDataFormat(“yyyy-MM-dd”);
字符串日期=dt1.格式(indate);
最终StringBuilder=新StringBuilder(“”);
针对(最终行动:行动){
if(action.getChecked()){
builder.append(“;”);
append(action.getActionid());
}
}
字符串lstAction=builder.toString();
lstAction=lstAction.substring(1);
字符串[]arrAction=lstAction.split(“;”);
cars=carService.search(日期、排列);
//返回结果;
//setModel(新的ListModelList(结果));
}
但当我选择另一天时,我无法重新加载网格 请给我任何解决办法
谢谢大家

为什么要将param绑定到带有@bindingparm(“indate”)的函数

如果将日期值与此绑定:

<datebox style ="z-index: 100000;" format="yyyy-MM-dd" value ="@bind(vm.date)"
onChange="@global-command('dataChanged', indate = infrom.value)" /> 
在listCars函数中,不在其中使用@BindingParam

相反,您需要声明

private Date date;

在viewmodel中,使用他的getter和setter。

感谢您的帮助。但是我发现了我的错误并解决了它们。我注意到了你的理想
private Date date;