Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
660 views
in Technique[技术] by (71.8m points)

jquery - Using jqGrid's emptyrecords option

So I have this grid. It's a very nice grid. Lovely, really. Except when I have nothing to populate it with. In that case, I'd really like to display a message indicating that, "No URLs have been loaded for evaluation.", but either I'm missing something critical or the emptyrecords option isn't behaving the way I'd expect. Can someone point me in the right direction?

var pages = <?php echo $json_encoded_array ?>;

$('#oversight-sample').jqGrid({
  altRows:   true,
  autowidth: true,
  caption:   'Evaluated URLs',
  colNames:  ['Actions', 'URL', 'Fetch Date'],
  colModel:  [
    { align: 'center', name: 'actions', index: 'actions', title: false, width: 60, resizable: false, sortable: false },
    { name: 'url', index: 'url', width: 400 },
    { align: 'center', name: 'created', index: 'created', width: 125, sorttype: 'date' }
  ],
  data:         pages,
  datatype:     'local',
  emptyrecords: 'No URLs have been loaded for evaluation.',
  forceFit:     true,
  height:       'auto',
  hoverrows:    true,
  sortname:     'created',
  pager:        '#url-pager',
  viewrecords:  true
});

If records do exist, then everything looks about like I'd expect it to look. Is there something else I need to do to get the emptyrecords message to display when there are none?

I'm using jqGrid 3.8.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should verify how are the value of data parameter (the value of pages in your case). I suppose the value is null or {} instead of [].

UPDATED: You can also consider to set current page from 1 to 0 how it shows the small demo.

UPDATED 2: Of cause you can place the text about empty rows on the place of the table. In the case you have to remove height: 'auto' to be able to see the text. Look at another demo which show this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...