I need to replace the ADVANCED filter options for a column with a custom selection set.
The column data is being supplied to the grid as an integer value and reformated
{ headerText: "Role", key: "RoleID", width: "100px", dataType: "string", formatter: formatUserRoleCombo },
The column is being edited via combo with datasource 'userRoleJSON' supplying integer 'Value' and string 'Name'.
I want this datasource to be used to fill the filter combo options when filtering on this combo.
The selected integer value NOT the text should be used to filter the grid.
I am using the code below on a loader after the grid is initialised to attempt to attach the combo to column 16.
However the combo is not being attached to any column filter.
Can anyone advise here.
Thank You.
$($('tr[data-role="filterrow"] td')[16]).append("<div id='filterUserRoleCombo'></div>");
$("#filterUserRoleCombo").igCombo({
dataSource: userRoleJSON,
textKey:"Name",
valueKey:"Value",
mode:"dropdown",
width:"100%",
selectionChanged:
function (evt, ui) {
var expressions = $("#GridTable").data("igGrid").dataSource.settings.filtering.expressions;
$("#GridTable").data("igGrid").dataSource.settings.filtering.expressions = [];
var newExpressions = [];
if (expressions.length !== 0) {
for (var i = 0; i < expressions.length; i++) {
if (expressions[i].fieldName !== "RoleID") {
newExpressions.push({
fieldName: expressions[i].fieldName,
expr: expressions[i].expr,
cond: expressions[i].cond
});
}
if ((ui.items !== null) && (ui.items.length === 1)) {
fieldName:"RoleID",
expr: ui.items[0].text,
cond:"equals"
$("#GridTable").igGridFiltering("filter", newExpressions);
Hi Petar,
Any update on this one please?
Regards,
Jasdeep
I'm getting an error "Unable to get property 'show' of undefined or null reference".
Also I have filtering type remote. Please see an attached error.
Hello Jasdeep,
Please feel free to contact me if you have any further questions regarding this matter.
Thank you for your patience.
In this scenario I would suggest using the filtering feature'sfiltermethod (note that methods beginning with an underscore are private and may change without notice).
http://help.infragistics.com/NetAdvantage/jQuery/2013.1/CLR4.0?page=igGrid_Filtering.html
For instance:
<script type="text/javascript"> localStorage.setItem("companyNameFilter", JSON.stringify([{expr:'a', cond: 'startsWith', fieldName: 'CompanyName'}])); function filterCompanyName() { var filterCondition = JSON.parse(localStorage.getItem("companyNameFilter")); $("#grid1").igGridFiltering("filter", filterCondition, true); } </script>
<script type="text/javascript"> localStorage.setItem("companyNameFilter", JSON.stringify([{expr:'a', cond: 'startsWith', fieldName: 'CompanyName'}]));
function filterCompanyName() { var filterCondition = JSON.parse(localStorage.getItem("companyNameFilter")); $("#grid1").igGridFiltering("filter", filterCondition, true); }
</script>
Note that the same approach may be used irrespectively of the filtering mode.
Attached is a modified version of the custom filtering sample illustrating this in practice (a button to add a 'startsWith' filter is added below the grid).
Feel free to contact me if you have any questions.
Thank you for your reply.
I am currently looking into whether and how this would be achievable and will keep you posted of my progress.