0

我正在发送这样的 Json 数据

var books = bookInfoService.GetAllBookInfo(1);
            var bookList = from w in books
                           from x in w.BookAuthors
                           select new
                           {
                               authorName = x.Authors.Name

                           };

var bookShelfs = bookShelfService.GetAllBookShelfs(1);
var jsonData = from w in bookShelfs select new { w.Id, w.Price, w.BarcodeId, w.BookInfos_s.Title, w.BookInfos_s.BookCategories.CategoryName,bookList};
return Json(jsonData, JsonRequestBehavior.AllowGet);

在 Jqgrid 中,我有一列显示 authorName 的值。该列的代码如下所示。

{ name: 'authorName', width: 180, align: 'center', editable: false },

和我的萤火虫显示数据,如

[{"Id":1,"Price":23,"BarcodeId":1000,"Title":"HeadFirst C#","CategoryName":"Book","bookList":[{"autorId":1," authorName":"Skiena"}]}

我想在 authorName 列中获取作者姓名。但是我该怎么做呢?是否可以在 jsonData 中传递作者姓名?喜欢

var jsonData = from w in bookShelfs select new { w.Id, w.Price, w.BarcodeId, w.BookInfos_s.Title, w.BookInfos_s.BookCategories.CategoryName} from s in books select new{s.Authors.Name};
4

1 回答 1

0

您可以直接从网格的 json 表示中获取该信息。例子 :

//get the data(json) of the grid
var gridData = yourJqgrid.getRowData();
var myRandomCell = gridData[rowNumber].cellName

也结帐:http ://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods 希望这会有所帮助!

于 2013-11-07T05:43:41.343 回答