jQuery UI Widgets › Forums › Grid › grid getrows
Tagged: angular grid, clearfilters, custom filter, filter, grid, jquery grid, jqxgrid, single-page application, SPA
This topic contains 10 replies, has 3 voices, and was last updated by Rajesh 7 years, 11 months ago.
-
Authorgrid getrows Posts
-
Hi
its urgent please reply as soon as possible
i am using $(“#jqxgrid”).jqxGrid(‘getrows’) method but we are not getting actual count of row which are getting from server
some time miss one record or some times increase count
i.e we are getting 5 records from server but grid show only 4 rows , even i set grid pagesize 5 and some time server return 1 row but grid show rows 4 rows empty row- This topic was modified 7 years, 11 months ago by Rajesh. Reason: miss words
Hi Rajesh,
Send an example of your code to investigate the problem.
Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comHi Ivailo Ivanov,
Thanks for reply,
i think problem is solved but i am facing another critical problem i am using single page application i am using custom filter for multichoice filter when we visit first time to page filter is working fine but whenever i am come again on page form another page filter not working when i inspect html i saw grid create no of filter panel instants(i.e if i visit page 3 time open filter panel grid create 3 same filter panel) so is there any way whenever i click on icon for open filter panel will remove existing filter panel and then load new filter panel or reload filter panel every time.
here is may code
we r using generic code of custom filter for all grid
this is column in grid
{ text: ‘job status’, datafield: ‘JobStatus’, editable: false, minwidth: 100, width: ‘auto’, cellsrenderer: toolTipRenderer,
filtertype: “custom”,
createfilterpanel: function (datafield, filterPanel) {
buildFilterPanelMultiChoice(filterPanel, datafield, ‘Diagnostic Job Status’);
}
},fro call generic filter function
var buildFilterPanelMultiChoice = function (filterPanel, datafield, name) {
genericBuildFilterPanelMultiChoice(filterPanel, datafield, dataAdapter, gID, name);
}generic function in utility
function genericBuildFilterPanelMultiChoice(filterPanel, datafield, dataAdapter, gId, name) {
var filterInfo = $(“#” + gId).jqxGrid(‘getfilterinformation’);
var storedFilterArr = new Array();
for (i = 0; i < filterInfo.length; i++) {
if (filterInfo[i].filtercolumn == datafield) {
storedFilterArr = filterInfo[i].filter.getfilters()[0].value.split(‘^’);
}
}var checkArr = getMultiCoiceFilterArr(name);
var inputdiv = $(‘<div class=”col-md-4″ style=”height:400px;”></div>’);
var strinput=”;
strinput+='<div class=”grid-pop” style=”width:216px;”>’;
strinput += ‘<div class=”con-area” style=”display: block;height: 110px;overflow-y: auto;width: 214px;” id=”‘ + gId + datafield + ‘div”>’;
for (var i = 0; i < checkArr.length; i++) {
if ($.inArray(checkArr[i].Value,storedFilterArr) < 0) {
//alert(‘if’);
strinput += ‘<div class=”checkbox”>’;
strinput += ‘<label>’;
strinput += ‘<input type=”checkbox” class=”checkItem” value=”‘ + checkArr[i].ControlValue + ‘”>’ + checkArr[i].Value;;
strinput += ‘</label>’;
strinput += ‘ </div>’;} else {
//alert(‘else’);
strinput += ‘<div class=”checkbox”>’;
strinput += ‘<label>’;
strinput += ‘<input type=”checkbox” checked=true class=”checkItem” value=”‘ + checkArr[i].ControlValue + ‘”>’ + checkArr[i].Value;
strinput += ‘</label>’;
strinput += ‘ </div>’;}
}
strinput+='</div>’;
strinput+='<div class=”btn-footer”>’;
strinput += ‘ <span id=”‘ + gId + datafield + ‘multichClear” class=”btn btn-default”>’ + i18n.t(‘reset’, { lng: lang }) + ‘</span>’;
strinput += ‘ <span id=”‘ + gId + datafield + ‘multichFilter” class=”btn btn-primary”>’ + i18n.t(‘go’, { lng: lang }) + ‘</span>’;
strinput+=’ </div>’;
strinput+='</div>’;inputdiv.append(strinput);
filterPanel.append(inputdiv);if (filterInfo.length > 0) {
$(“#” + gId + datafield + “multichClear”).attr(‘disabled’, false);
}
var dataSource =
{
localdata: dataAdapter.records,
async: false
}
var dataadapter = new $.jqx.dataAdapter(dataSource,
{
autoBind: false,
autoSort: true,
async: false,
uniqueDataFields: [datafield]
});
var column = $(“#” + gId).jqxGrid(‘getcolumn’, datafield);$(“#” + gId + datafield + “multichFilter”).on(“click”, function () {
var filtergroup = new $.jqx.filter();
var selectedFilterValue = ”;
$(“#” + gId + datafield + “div”).find(“input:checkbox”).each(function (i, ob) {
if ($(ob).is(‘:checked’)) {
selectedFilterValue += $(ob).val() + ‘^’;
}
});
selectedFilterValue = selectedFilterValue.substring(0, selectedFilterValue.length – 1)
var filter_or_operator = 1;
var filtervalue = selectedFilterValue;
var filtercondition = ‘contains’;
var filter1 = filtergroup.createfilter(‘stringfilter’, filtervalue, filtercondition);
filtergroup.addfilter(filter_or_operator, filter1);// add the filters.
$(“#” + gId).jqxGrid(‘addfilter’, datafield, filtergroup);// apply the filters.
$(“#” + gId).jqxGrid(‘applyfilters’);
$(“#” + gId).jqxGrid(‘closemenu’);});
$(“#” + gId + datafield + “multichClear”).on(“click”, function () {
$(“#” + gId).jqxGrid(‘removefilter’, datafield);
// apply the filters.
$(“#” + gId).jqxGrid(‘closemenu’);});
}
- This reply was modified 7 years, 11 months ago by Rajesh. Reason: modify words
Hi Rajesh,
You can set boolean variable to prevent creating of new filters in every page visit.
Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comHi Ivailo Ivanov,
thanks for help but could you please provide sample code or link fro example actually i didn’t get where and how i can set Boolean variable
Hi Rajesh,
Try
`if((typeof(filtergroup) === “undefined”) || (filtergroup === null)){
var filtergroup = new $.jqx.filter();
}`Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comhi Ivailo Ivanov
Thanks fro reply
but this is not work for me.
actually on first visit on page all thinks working fine then go to other page there also firs time filter works fine then whenever we back to page and open filter panel then filter panel visible but not fire any event like filter, reset, or change any value in input fields etc…even if i change value for any input fields(i.e check box or textbox) of filter panel not change..
Hi Rajesh,
Please try the following:
$("#" + gId + datafield + "multichFilter").on("click", function() { $("#" + gId).jqxGrid('clearfilters'); var filtergroup = new $.jqx.filter(); var selectedFilterValue = "; $("#" + gId + datafield + "div").find("input:checkbox").each(function(i, ob) { if ($(ob).is(':checked')) { selectedFilterValue += $(ob).val() + '^'; } }); selectedFilterValue = selectedFilterValue.substring(0, selectedFilterValue.length– 1) var filter_or_operator = 1; var filtervalue = selectedFilterValue; var filtercondition = 'contains'; var filter1 = filtergroup.createfilter('stringfilter', filtervalue, filtercondition); filtergroup.addfilter(filter_or_operator, filter1); // add the filters. $("#" + gId).jqxGrid('addfilter', datafield, filtergroup); // apply the filters. $("#" + gId).jqxGrid('applyfilters'); $("#" + gId).jqxGrid('closemenu'); });
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/HI
Thanks for reply but its not working we are using server side filter that way is give data still loading error whenever i click on filter button
so its not work for me.Hi Rajesh,
You should make sure one server-side operation has been completed before querying another one. You can use the bindingcomplete event for this.
Other than that we cannot be of much assistance to you, because your project seems fairly complicated and customized and the issues are related more to your custom code than the widgets themselves. Please check out some existing demos, tutorials or forum topics on the matter, where you may find insights to the right approach.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar
Thanks,
-
AuthorPosts
You must be logged in to reply to this topic.