如果选中复选框,请更改单元格值 - dhtmlxGrid in RoR [英] Change cell value if checkbox selected - dhtmlxGrid in RoR

查看:1451
本文介绍了如果选中复选框,请更改单元格值 - dhtmlxGrid in RoR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在RoR上使用dhtmlxGrid。我有一个复选框和一个事件onCheck,每次复选框被选中时被激活。

 < script type = text / javascriptcharset =utf-8> 
var grid = new dhtmlXGridObject(grid_here);
grid.setImagePath(/ images / dhtmlx / imgs /);
grid.setHeader(Result,PatientID,Approved,Status,Approved Date);
grid.attachHeader(#text_filter,#text_filter,#text_filter,#text_filter,#text_filter);
grid.setColTypes(txt,ed,ch,co,ed);
grid.setColSorting(str,str,str,str,date);
grid.setInitWidths(100,100,*);
grid.setSkin(dhx_skyblue);
grid.init();
grid.load(/ approves / data);
grid.attachEvent(onCheck,doOnCheckBoxSelected);

dp = new dataProcessor(/ approves / dbaction.xml);
dp.init(grid);

function doOnCheckBoxSelected(rID,cInd,state)
{
if(state =='1')
{alert(date approved);}

}
< / script>

当我选中任何复选框时,alert现在我想做的是在选中复选框时自动更改单元格状态和批准日期中的值。该复选框称为已批准,当人们点击已批准复选框时,我想要将名为批准日期的单元格自动更新为当前日期,并将状态更改为已批准。 p>

我不知道如何在网格单元格中存储新值。我如何做到这一点,是可能吗?

解决方案

您已经有了要更新的rowId,因此您只需要告诉网格设置您想要的列的值,并将该行标记为更新为您的数据处理程序检测更改

 函数doOnCheckBoxSelected(rID,cInd,state){
if(state =='1 '){
alert(date approved);
}
var currentDate = new Date(); //这只是一个例子,在这里你可以生成你希望的格式的日期。
/ *这里是列索引,其中日期或状态是...
在这种情况下,我假设在列3是状态和4批准日期,将它们更改为你的
真实索引* /
grid.cells(rID,3).setValue('Approved');
grid.cells(rID,4).setValue(currentDate);

dp.setUpdated(rID,true); //你告诉数据处理器该行已更新,所以它将该行标记为已更新
return true; //如果我正确地回忆起这个函数需要正确结束,也许不是
}


I'm using dhtmlxGrid on RoR. I have a checkbox and an event "onCheck" that gets activated each time the checkbox is checked.

<script type="text/javascript" charset="utf-8">
        var grid = new dhtmlXGridObject("grid_here");
        grid.setImagePath("/images/dhtmlx/imgs/");
        grid.setHeader("Result, PatientID, Approved, Status, Approved Date");
        grid.attachHeader("#text_filter,#text_filter,#text_filter,#text_filter,#text_filter"); 
        grid.setColTypes("txt,ed,ch,co,ed");
        grid.setColSorting("str,str,str,str,date");  
        grid.setInitWidths("100,100,*");
        grid.setSkin("dhx_skyblue");
        grid.init();
        grid.load("/approves/data");
        grid.attachEvent("onCheck",doOnCheckBoxSelected);

        dp = new dataProcessor("/approves/dbaction.xml");
        dp.init(grid);

        function doOnCheckBoxSelected(rID, cInd, state)
        {
            if (state=='1')
                {alert("date approved");}

        }
    </script>

The "alert" world fine when I check any checkbox. What I want to do now, is to automatically change the values in the cells "Status" and "Approved Date", when the checkbox is checked. The checkbox is called "Approved" and when people click on the "Approved" checkbox, I want the cell called "Approved Date" to be automatically updated with the current date, and the "Status" to change to "Approved".

I don't know how to store new values inside a grid cell.. How can I do this, is it possible?

解决方案

you already have the rowId you want to update, so you only need to tell the grid to set the values on the columns you want, and mark the row as updated for your dataprocessor to detect the change

function doOnCheckBoxSelected(rID, cInd, state){
    if (state=='1'){
        alert("date approved");
    }
    var currentDate = new Date(); //This is just an example, here you can generate the Date in the format you wish.
    /*Here goes the column index in which the date or status are...
    In this case I'm assuming in the column 3 is the Status and in 4 the Date of approval, change them to your 
    real indexes*/
    grid.cells(rID,3).setValue('Approved');
    grid.cells(rID,4).setValue(currentDate);

    dp.setUpdated(rID,true); //You tell your dataProcessor that the row was updated, so it mark the row as updated
    return true; //if i recall correctly this is needed for the function to end correctly, maybe not
}

这篇关于如果选中复选框,请更改单元格值 - dhtmlxGrid in RoR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆