从表格单元格中获取值

时间:2013-02-28 13:58:05

标签: javascript jquery drupal

我有这部分代码:

$.ig.loader(function () {
$("#grid2").igGrid({

autoGenerateColumns: false,
renderCheckboxes: true, 

columns:[                
            { headerText: "#", key: "#", dataType: "number", width: "40%"},
            { headerText: "filename", key: "fieldname", dataType: "image", width: "40%"},
            { headerText: "X", key: "x", dataType: "number", width: "40%"},
            { headerText: "Y", key: "y", dataType: "number", width: "40%"},
            { headerText: "Z", key: "z", dataType: "number", width: "40%"},

        ],

//dataSource: data,

height: "400px",
width: "100%",
features:[
            {
                name: "Filtering",
                allowFiltering: true,
                type: "local"
            },
            {
                name: "Selection",
                mode: "row"
            },
            {
                name: "Updating",
                enableAddRow: false,
                editMode: "row",
                // event raised after end row editing but before dataSource was updated
                editCellEnding: function (evt, ui) {
                    // get cell’s checkbox value when it is changed
                    if (ui.update) {
                        if (ui.columnKey === "nid") {
                            logEvent("editCellEnded event fired. Column Key = " +
                        ui.columnKey + "; Row Index = " +
                        ui.rowID + "; Cell Value = " +
                        ui.value + "; Update = " +
                        ui.update);
                        }
                    }
                },
                enableDeleteRow: false,
                columnSettings: [
                {
                columnKey: "#", 
                },
                {
                columnKey: "fieldname",
                },

                {
                    columnKey: "x",

                }, 
                {
                    columnKey: "y"
                }, 
                {
                    columnKey: "z"
                }]
            }

        ]
});

$.ajax({
    type: "POST",
    url: "http://cmsdemo.trueoffice.com/feature-json2",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(data){
        $("#grid2").igGrid({
        dataSource: data 
        });
     }
     });
    $("#grid2").live("iggridupdatingdatadirty", function (event, ui) {
            $("#grid2").igGrid("commit");
            return false;
        });
    // show the raised event
        function logEvent(message) {
            var evntWrap = $("#eventList");
            $(evntWrap).append("<div>" + message + "<div>");
            $(evntWrap).prop("scrollTop", $(evntWrap).prop("scrollHeight"));
        }
      });

//Functions         
function Filter() {
      var columnSettings = $("#grid1").igGridFiltering("option", "columnSettings");

        var expr = $("#filterExpr").val(),
            condition = $("#cond_list").val(),
            filterColumn = $("#filterColumn").val();
        $("#grid1").igGridFiltering("filter", ([{fieldName: filterColumn, expr: expr, cond: condition}]));
    }

    function SetConditions() {
        var filterColumn = $("#filterColumn").val();
        $("#cond_list option:selected").removeAttr("selected");
        if (filterColumn === "title" || filterColumn === "nid") {
         $("#cond_list .stringCondition").attr("disabled", "disabled");
         $("#cond_list .numberCondition").removeAttr("disabled").eq(0).attr("selected", "selected");
        }
        else {
            $("#cond_list .stringCondition").removeAttr("disabled").eq(0).attr("selected", "selected");
            $("#cond_list .numberCondition").attr("disabled", "disabled");
        }
    }
    function buttonClickHandler(buttonId) {
    alert("Button with id " + buttonId + " was clicked");
}

和这部分代码

<script>
    var layer1 = document.getElementById('layer1');
    ctx1 = layer1.getContext('2d'); 
    var item1 = new Image();
    item1.src = "<?php echo $base_url;?>/themes/bartik/images/sheep.png";
    item1.addEventListener("load", function() {
    ctx1.clearRect(0,0,1024,768)
    ctx1.drawImage(item1,x,y)}, false); //how to get values from a table row?   
</script>

我的问题是:如何从第一行表中获取值并将其发送到ctx1.drawImage(item1,x,y)。

如果有必要,我可以复制/粘贴其余代码。

0 个答案:

没有答案