jQWidgets Forums

Forum Replies Created

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts

  • harishkpv
    Participant

    Thanks!


    harishkpv
    Participant

    Thanks! That worked.


    harishkpv
    Participant

    Hi Peter,

    This is the code which is used for displaying data

    function displaygrid(objectid, storeprocedure, itemID, webpartid, requestServiceURL) {
    
        var initialRelationshiplevel = 0;
    
        dataFieldArray = buildDataArray(metadata, "");
        var strColumnDisplay = Enumerable.From(metadata)
        .Where(function (x) { return x.category === "Column Control" && x.key === "Columns"; })
        .Select(function (x) { return x.value; }).ToString();
    
        var arrColumnDisplay = strColumnDisplay.split(",");
        columnsArray = buildColumnArray(metadata, arrColumnDisplay, requestServiceURL);
    
        var TreeProperty = new TreeRenderProperty.TreeRenderProperty(metadata);
    
        var treeIDColumn = TreeProperty.TreeIDColumn;// getTreeIDColumn(metadata);
        var treeParentIDColumn = TreeProperty.TreeParentIDColumn; //getTreeParentIDColumn(metadata);
        var treeParentNodeIdentifier = TreeProperty.ParentNodeIdentifier; //getTreeLabel(metadata);
        var rootcitype = TreeProperty.RootCIType;// getRootCIType(metadata);
        var treeDepth = TreeProperty.TreeDepth;
        var theme = getDemoTheme();
    
        var gridsource =
                {
                    dataType: "jsonp",
                    dataFields: dataFieldArray,
                    hierarchy:
                    {
                        keyDataField: { name: "TempUniqueField" },
                        parentDataField: { name: treeParentIDColumn }
                    },
                    id: "TempUniqueField",
                    root:'',
                    url: requestServiceURL + "/Relation/"
                };
    
        $("#treeGrid_" + webpartid).jqxTreeGrid(
                   {
                       width: _width * 0.99,
                       //source: adapter,
                       sortable: false,
                       columnsResize: true,
                       virtualModeCreateRecords: function (expandedRecord, done) {
                           var adapter = new $.jqx.dataAdapter(gridsource, {
                               formatData:function(data){
                                   if (expandedRecord === null){
                                       data.storedProc = storeprocedure;
                                       data.itemID = itemID + "~" + rootcitype;
                                       data.depth = 1;
                                   }
                                   else {
                                       var nodekey = $("#treeGrid_" + webpartid).jqxTreeGrid('getKey', expandedRecord);
                                       var itemParam = (expandedRecord.LinkKey === null ? (itemID + "~" + rootcitype) : expandedRecord.LinkKey + "~" + expandedRecord.ItemTier2);
                                       if ($("#treeGrid_" + webpartid).jqxTreeGrid('getRow', nodekey).parent !== undefined) {
                                           var parent = $("#treeGrid_" + webpartid).jqxTreeGrid('getRow', nodekey).parent;
                                           var parentCIName = parent[treeParentNodeIdentifier];
                                           itemParam = encodeURIComponent(itemParam + "~" + parentCIName);
                                       }
                                       data.storedProc = storeprocedure;
                                       data.itemID = itemParam;
                                       data.depth = 2;
                                   }
                                   return data;
                               },
                               downloadComplete: function (edata, textStatus, jqXHR) {
                                   if (edata !== "[]") {
                                       var data = $.parseJSON(edata);
                                       return data;
                                   }
                                   else {
                                       
                                       return $.parseJSON("[{}]");
                                   }
                               },
                               loadComplete: function () {
                                   done(adapter.records);
                               },
                               loadError: function (xhr, status, error) {
                                   done(false);
                                   throw new Error(error.toString());
                               }
                           });
                           adapter.dataBind();
                       },
                       virtualModeRecordCreating: function (record) {
    
                           if (record.level == treeDepth) {
                               record.leaf = true;
                           }
                       },
                       columns: columnsArray
                   });
    }

    The condition (edata !== “[]“) has been added to prevent the page from going in loop to access data. When no data is present, the url returns “[]“.
    If data is present (this is the first node in both cases), JSON is as below,

    [{"TempRelationID":1,"TempUniqueField":null,"DisplayCIName":"LNAPP016A","RelatedCIName":null,"DisplayCIReconciliationId":"RE219890227800SNvwMGiUAA3gUB",
    "ItemTier1":null,"ItemTier2":null,"ItemType":null,"ItemRelType":null,"RelatedItemTier1":null,"RelatedItemTier2":null,"RelatedItemType":null,
    "RelatedItemRelType":null,"LinkKey":null,"LinkURL":null,"ParentCIName":"108","ParentID":-1,"ChildCIName":"108","ParentCIReconciliationId":null,
    "ChildCIReconciliationID":null,"RelationShipName":null,"RelationshipLevel":0,"RelationshipPath":"108","HasChildren":false}]

    I am using 3.2.2 version.

    Please suggest

    Regards,
    Harish


    harishkpv
    Participant

    Hi Peter,

    The code is as below,

    var gridsource =
    {
    dataType: “jsonp”,
    dataFields: dataFieldArray,
    hierarchy:
    {
    keyDataField: { name: “TempUniqueField” },
    parentDataField: { name: treeParentIDColumn }
    },
    id: “TempUniqueField”,
    root:”,
    url: requestServiceURL + “:8085/Relation/”
    };

    $(“#treeGrid_” + webpartid).jqxTreeGrid(
    {
    width: _width * 0.99,
    //source: adapter,
    sortable: false,
    columnsResize: true,
    //ready: function () {
    // $(“#treeGrid_” + webpartid).jqxTreeGrid(‘expandRow’, ‘2’);
    //},
    virtualModeCreateRecords: function (expandedRecord, done) {
    var adapter = new $.jqx.dataAdapter(gridsource, {
    formatData:function(data){
    if (expandedRecord === null){
    data.storedProc = storeprocedure;
    data.itemID = itemID + “~” + rootcitype;
    data.depth = 1;
    }
    else {
    var nodekey = $(“#treeGrid_” + webpartid).jqxTreeGrid(‘getKey’, expandedRecord);
    var itemParam = (expandedRecord.LinkKey === null ? (itemID + “~” + rootcitype) : expandedRecord.LinkKey + “~” + expandedRecord.ItemTier2);
    if ($(“#treeGrid_” + webpartid).jqxTreeGrid(‘getRow’, nodekey).parent !== undefined) {
    var parent = $(“#treeGrid_” + webpartid).jqxTreeGrid(‘getRow’, nodekey).parent;
    var parentCIName = parent[treeParentNodeIdentifier];
    itemParam = encodeURIComponent(itemParam + “~” + parentCIName);
    }
    data.storedProc = storeprocedure;
    data.itemID = itemParam;
    data.depth = 2;
    }
    return data;
    },
    downloadComplete: function (edata, textStatus, jqXHR) {
    if (edata !== “[]”) {
    var data = $.parseJSON(edata);
    return data;
    }
    //else {

    // return $.parseJSON(“[{null}]”);
    //}
    },
    loadComplete: function () {
    done(adapter.records);
    },
    loadError: function (xhr, status, error) {
    done(false);
    throw new Error(error.toString());
    }
    });
    adapter.dataBind();
    },
    virtualModeRecordCreating: function (record) {

    if (record.level == treeDepth) {
    record.leaf = true;
    }
    },
    columns: columnsArray
    });

    The condition (edata !== “[]”) has been added to prevent the page from going in loop to access data. When no data is present, the url returns “[]”.
    If data is present (this is the first node in both cases), JSON is as below,

    [{“TempRelationID”:1,”TempUniqueField”:null,”DisplayCIName”:”LNAPP016A”,”RelatedCIName”:null,”DisplayCIReconciliationId”:”RE219890227800SNvwMGiUAA3gUB”,
    “ItemTier1″:null,”ItemTier2″:null,”ItemType”:null,”ItemRelType”:null,”RelatedItemTier1″:null,”RelatedItemTier2″:null,”RelatedItemType”:null,
    “RelatedItemRelType”:null,”LinkKey”:null,”LinkURL”:null,”ParentCIName”:”108″,”ParentID”:-1,”ChildCIName”:”108″,”ParentCIReconciliationId”:null,
    “ChildCIReconciliationID”:null,”RelationShipName”:null,”RelationshipLevel”:0,”RelationshipPath”:”108″,”HasChildren”:false}]

    I am using 3.2.2 version

    Please suggest.

    Regards,
    Harish


    harishkpv
    Participant

    Thanks!!


    harishkpv
    Participant

    Hi Peter,

    Got that error resolved. It needed addition of

    var gridsource =
    {
    dataType: “jsonp”,
    dataFields: dataFieldArray,
    hierarchy:
    {
    keyDataField: { name: “TempRelationID”},
    parentDataField: { name: “ParentID”}
    },
    id: treeIDColumn,
    root:”,
    url: requestServiceURL + “:8085/Relation/”
    };

    $(“#treeGrid_” + webpartid).jqxTreeGrid(
    {
    width: _width * 0.99,
    //source: adapter,
    sortable: false,
    columnsResize: true,
    ready: function () {
    $(“#treeGrid_” + webpartid).jqxTreeGrid(‘expandRow’, ‘2’);
    },
    virtualModeCreateRecords: function (expandedRecord, done) {
    var adapter = new $.jqx.dataAdapter(gridsource, {
    formatData:function(data){
    if (expandedRecord === null){
    data.storedProc = storeprocedure;
    data.itemID = itemID;
    data.depth = 2;
    }
    else {
    alert(“row”);
    }
    },
    downloadComplete: function (edata, textStatus, jqXHR) {
    var data = $.parseJSON(edata);
    return data;
    }
    ,
    loadComplete: function () {
    done(adapter.records);
    },
    loadError: function (xhr, status, error) {
    done(false);
    throw new Error(error.toString());
    }
    });
    adapter.dataBind();
    },
    virtualModeRecordCreating: function (record) {
    if (record.level === 2) {
    record.leaf = true;
    }
    },
    columns: columnsArray
    });

    Also, corrected the JSON.
    The JSON is now,
    [{“TempRelationID”:1,”DisplayCIName”:”Acrobat Distiller”,”RelatedCIName”:null,”DisplayCIReconciliationId”:”RE219848167700cXUAIyHV4Acw”,”ItemTier1″:null,”ItemTier2″:null,”ItemType”:null,”ItemRelType”:null,”RelatedItemTier1″:null,”RelatedItemTier2″:null,”RelatedItemType”:null,”RelatedItemRelType”:null,”LinkKey”:null,”LinkURL”:null,”ParentCIName”:”Acrobat Distiller”,”ParentID”:null,”ChildCIName”:”Acrobat Distiller”,”ParentCIReconciliationId”:null,”ChildCIReconciliationID”:null,”RelationShipName”:null,”RelationshipLevel”:0,”RelationshipPath”:”0″,”HasChildren”:true},{“TempRelationID”:2,”DisplayCIName”:”N2VAPP047 (Child)”,”RelatedCIName”:”Acrobat Distiller”,”DisplayCIReconciliationId”:”RE219890227800R8XQnnWIMA20gP”,”ItemTier1″:”Hardware”,”ItemTier2″:”Server”,”ItemType”:”Virtual Server”,”ItemRelType”:”Runs”,”RelatedItemTier1″:”Software”,”RelatedItemTier2″:”Application”,”RelatedItemType”:”Application Instance”,”RelatedItemRelType”:”Runs On”,”LinkKey”:”914″,”LinkURL”:”/Pages_Servers/ServerItemDetail.aspx”,”ParentCIName”:”Acrobat Distiller”,”ParentID”:1,”ChildCIName”:”N2VAPP047″”,”ParentCIReconciliationId”:”RE2198487700SmcXUAIyHV4AcwkB”,”ChildCIReconciliationID”:”RE219890227800RV#8XQnnWA20gP”,”RelationShipName”:”Acrobat Distiller Runs On N2VAPP047″”,”RelationshipLevel”:1,”RelationshipPath”:”1″,”HasChildren”:false}]

    However, having a problem with the display. Instead of showing in hierarchical format, 2 rows are getting shown.

    Please suggest.

    Regards,
    Harish

Viewing 6 posts - 1 through 6 (of 6 total)