This is a migrated thread and some comments may be shown as answers.

DataSource transport.read does not fire complete event

1 Answer 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
zhang
Top achievements
Rank 1
zhang asked on 05 Jul 2015, 07:30 AM

Hi,this code not fire complete event:

$(document).ready(function () {
    var ds = new kendo.data.DataSource({
        transport: {
            read: {
                url: "/api/Base/QueryData",
                dataType: "json",
                type: "post",
                contentType: "application/x-www-form-urlencoded",
                data: {
                    PrimaryTable: "Employee",
                    PrimaryKeyField: "EID",
                    FieldNameList: "EID,EmpName,sex",
                    ConditionExpr: "EID=85"
                },
                beforeSend: function (xhr) {
                    //xhr.setRequestHeader('Authorization', window.auth);
                },
                complete: function (jqXHR, textStatus) {
                    console.log(jqXHR);
                }
            }
        }
    });
    $("#divQJList").kendoGrid({
        dataSource: ds
    });
});

 

the api/Base/QueryData code like this:

[Route("QueryData")]
public GRDataSet QueryData([FromBody]JObject jo)
{
    GRDataSet grData = new GRDataSet();
    grData.Table = new DBTable();
    grData.Table.FieldList = new ObservableCollection<DBField>();

    ........
    DataSet ds = GetData(jo);
    grData.DataXML = XDocument.Parse(ds.GetXml());
    return grData;
}
response return json:

{
    "Table": {
        "TableName": "DS",
        "TableTypeID": 2,
        "TableTypeName": 0,
        "PrimaryKey": null,
        "TableOrder": 1,
        "TableLabel": "Employee Table",
        "FieldList": [
            {"TableName": "EMPLOYEE", "TableTypeId": 2, "ColName": "EID", "ColOrder": 10, "ColType": "INT IDENTITY", "ColWidth": 4, "ColPrecision": 0, "ColNull": 0, "ColDefault": "", "DisplayLabel": "ID" },
            {"TableName": "EMPLOYEE", "TableTypeId": 2, "ColName": "EMPNAME", "ColOrder": 1, "ColType": "VARCHAR", "ColWidth": 20, "ColPrecision": 0, "ColNull": 0, "ColDefault": "", "DisplayLabel": "Name" },
            {"TableName": "EMPLOYEE", "TableTypeId": 2, "ColName": "SEX", "ColOrder": 40, "ColType": "CHAR", "ColWidth": 1, "ColPrecision": 0, "ColNull": 1, "ColDefault": "", "DisplayLabel": "Sex" }
        ]
    },
    "DataXML": { "NewDataSet": { "DS": { "EMPLOYEE_EID": "85", "EMPLOYEE_EMPNAME": "系统管理员", "EMPLOYEE_SEX": "1" } } },
    "Total": 10
}

1 Answer, 1 is accepted

Sort by
0
zhang
Top achievements
Rank 1
answered on 05 Jul 2015, 07:35 AM

when i modify the api QueryData that it return as a string, it work ok.

[Route("QueryData")]
public string QueryData([FromBody]JObject jo)
{
    GRDataSet grData = new GRDataSet();
    grData.Table = new DBTable();
    grData.Table.FieldList = new ObservableCollection<DBField>();
    DataSet ds = GetData(jo);
    grData.DataXML = XDocument.Parse(ds.GetXml());
    JObject ret = JObject.FromObject(grData);
    return ret.ToString();
}

Tags
Grid
Asked by
zhang
Top achievements
Rank 1
Answers by
zhang
Top achievements
Rank 1
Share this question
or