Search code examples
javascriptshieldui

ShieldUi datagrid shows 'no data to display' if there is only a single data set result


I am using shieldui's grid to display some data. If there is only a single node of data, the table renders and says 'There is no data to display'. If there are two or more results, it shows fine. Here is the code I'm using to display the data -

$('.data-holder').shieldGrid({
    dataSource: {
         data: jsonFromXML.HistoricalQuotes.HistoricalQuote
    }
});

Multi-node xml like this below displays just fine -

<IRXML CorpMasterID="xxxxx">
  <HistoricalQuotes Ticker="xxx" Date="03/03/1992">
    <HistoricalQuote>
      <Bid>0</Bid>
      <Ask>0</Ask>
      <High>28.1643892082794</High>
      <Low>27.7277320112518</Low>
      <Volume>583524.1048</Volume>
      <Open>27.8368963105087</Open>
      <SharesOutstanding>0</SharesOutstanding>
      <Last>28.1643892082794</Last>
      <AdjustmentFactor>1.145063</AdjustmentFactor>
      <RollingEarnings>0</RollingEarnings>
      <ShortInterest>0</ShortInterest>
    </HistoricalQuote>
    <HistoricalQuote>
      <Bid>0</Bid>
      <Ask>0</Ask>
      <High>28.1643892082794</High>
      <Low>27.7277320112518</Low>
      <Volume>583524.1048</Volume>
      <Open>27.8368963105087</Open>
      <SharesOutstanding>0</SharesOutstanding>
      <Last>28.1643892082794</Last>
      <AdjustmentFactor>1.145063</AdjustmentFactor>
      <RollingEarnings>0</RollingEarnings>
      <ShortInterest>0</ShortInterest>
    </HistoricalQuote>
  </HistoricalQuotes>
</IRXML>

But if I get returned a single node of data like this, I get the 'no records to display message' -

<IRXML CorpMasterID="xxxxx">
  <HistoricalQuotes Ticker="xxx" Date="03/03/1992">
    <HistoricalQuote>
      <Bid>0</Bid>
      <Ask>0</Ask>
      <High>28.1643892082794</High>
      <Low>27.7277320112518</Low>
      <Volume>583524.1048</Volume>
      <Open>27.8368963105087</Open>
      <SharesOutstanding>0</SharesOutstanding>
      <Last>28.1643892082794</Last>
      <AdjustmentFactor>1.145063</AdjustmentFactor>
      <RollingEarnings>0</RollingEarnings>
      <ShortInterest>0</ShortInterest>
    </HistoricalQuote>
  </HistoricalQuotes>
</IRXML>

I read through the documentation I found and I don't see any limitations around this. Does anyone have any thoughts on this?

Any input at all is greatly appreciated.


Solution

  • I tried to reproduce the described issue but to no avail. On my side binding the grid to a single object show it and there is not "no records to display message". My setup is:

        var products = [{
            ProductID: 1,
            ProductName: "Chai",
            SupplierID: 1,
            CategoryID: 1,
            QuantityPerUnit: "10 boxes x 20 bags",
            UnitPrice: 18.0000,
            UnitsInStock: 39,
            UnitsOnOrder: 0,
            ReorderLevel: 10,
            Discontinued: false
        }];
    
    $("#grid1").shieldGrid({
                dataSource: {
                    data: products
                },
                columns: [
                { field: "ProductName", title: "ProductName", width: "330px" },
                { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "130px" },
                { field: "UnitsInStock", title: "Units In Stock", width: "130px" },
                { field: "Discontinued", width: "130px" }
                ]
            });
    

    What is yours setup? Also can you confirm that the jsonFromXML.HistoricalQuotes.HistoricalQuote contains one record? Also please note that this record needs to be in a json array like in my example. Can you confirm that when xml contain one record the object in jsonFromXML.HistoricalQuotes.HistoricalQuote is wrapped in an array?

    Regards, Kat