如何从infragistic表中获取值

时间:2013-03-05 09:30:51

标签: jquery html5 infragistics ignite-ui iggrid

我需要从单元格表中获取值。如果你知道怎么做,我会非常感激。

尝试几天,但我不知道如何获取columnID和ROWID

我发现了这个,但它不起作用

.igGrid( "getCellValue", rowId:object, colKey:string );

这是代码(如何从表中获取值)?

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

autoGenerateColumns: false,
renderCheckboxes: true, 

columns:[                
            { 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: "x",

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

        ]
});

$.ajax({
    type: "POST",
    url: "http://cmsdemo.trueoffice.com/feature-json",
    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");
}   

1 个答案:

答案 0 :(得分:2)

有时候IG非常令人沮丧。但是,你有几个选择。如果您只关心列,您可以查看...即,您隐藏了一些列,但您不需要访问它们,那么您只需在editRowEnd或{{1}时访问ui对象事件火灾。否则,您需要使用基础editRowEnding的{​​{1}}。以下是它的外观,包括网格:

dataSource