We are displaying count of results displayed based on "from & to date" search, we are facing issue that when there is empty results, than its displaying "-1" as result, but we want to display as "0"
html code is
<div class="delete_grid" >
<form name="frmSearch" method="post" action="">
<input type="text" id="post_at" name="post_at" />
<input type="text" id="post_at_to_date" value=""name="post_at_to_date" />
<input type="submit" name="search" value="search" id="searchButton">
</form>
</div>
javascript code is
var gridOption={
container : 'myGrid',
};
var mygrid=new Sigma.Grid(gridOption);
Sigma.Util.onLoad( Sigma.Grid.render(mygrid) );
$(".delete_grid").append("Number of Designs Sold : "+mygrid.dataset.getSize());
we are using sigma plugin : http://pastebin.com/ftfL6qnU
Not sure where you're getting -1
exactly, I'm guessing here maybe: mygrid.dataset.getSize()
?
In any case, you can probably use a ternary operator.
So let's say you need it there, use this: mygrid.dataset.getSize()<0?0:mygrid.dataset.getSize()
The complete line would become:
$(".delete_grid").append("Number of Designs Sold : "+(mygrid.dataset.getSize()<0?0:mygrid.dataset.getSize()));
mygrid.dataset.getSize()
is less then 0
, the value is set to 0
.mygrid.dataset.getSize()
is used.