How to remove range from form data source by Code

Hi,

Just wondering if someone can help me please. I have designed a form with three data sources.

InventDim,InventSum,InventSum1.

I have applied a range on InventSum and InventSum1 data source to only display those items are in stock.

there in another check box when user hit that check box it call a method from class and display only those items which are out of stock from main warehouse. thats all working fine except a small bit when we un tick that check box it doesn’t clear that range and still shows filtered data . I have tried InventSum_DS.reread refresh method but no result.

I will appreciate any help in due course.

Kind Regards,

Hi,

Did you try the following when untick your checkBox :

this.Query().datasourceNo(1).clearRanges();

yourDatasource_ds.executeQuery() ; or yourDataSource_ds.research(true);

let me know if it works for you

Regards,

Thomas

Hi Thomas ,

Thanks for you reply . this.query().dataSourceNo(1).ClearRanges() work though but not in my case this is my code behind check box .

public void clicked()

{

Container C;

Int i;

JS_WareHouseInvent WH = new JS_WareHouseInvent();

;

super();

if (Enf.value() == 1)

{

startLengthyOperation();

C = WH.OInENF(InventSum.inventDimId);

for (i = 0; i <= ConLen(C);i++)

{

InventSum_DS.query().dataSourceTable(tablenum(InventSum)).addRange(fieldnum(InventSum,ItemID)).value(SysQuery::value(conPeek(c,i)));

}

EndLengthyOperation();

}

else if (ENf.value() == 0)

{

InventSum_Ds.query().dataSourceName(‘InventSum’).clearRanges();

}

InventSum_Ds.executeQuery();

}

and datasource excute query

public void executeQuery()

{

showAvailable.value(strfmt(’((OnOrder != %1) || (PhysicalInvent != %2) || (Availphysical != %3) || (AvailOrdered != %4) || (Ordered != %5))’,

0,0,0,0,0));

Super()

}

so if i use that clearRanges() ; it throw me a compiler error as i have one more filter in execute query method which is suppose to be there all the time. How ever if i do not call that range then it is ok .

You can simply use clearRange() instead of clearRanges(). If a class offers one useful operation, it’s always useful to check whether there isn’t more useful stuff.

Another approach is to leave the range in place and change its value to SysQuery::valueUnlimited().

Hi Guys,

Issue resolved here is my code

public void clicked()

{

Container C;

Int i;

JS_WareHouseInvent WH = new JS_WareHouseInvent();

;

super();

if (Enf.value() == 1)

{

startLengthyOperation();

C = WH.OInENF(InventSum.inventDimId);

for (i = 0; i <= ConLen(C);i++)

{

InventSum_DS.query().dataSourceTable(tablenum(InventSum)).addRange(fieldnum(InventSum,ItemID)).value(SysQuery::value(conPeek(c,i)));

}

EndLengthyOperation();

}

else if (ENf.value() == 0)

{

InventSum_Ds.query().dataSourceName(‘InventSum’).clearRanges();

InventSum_Ds.init();

}

InventSum_Ds.executeQuery();

}

all i am doing is that i am calling init method once again after clearing the ranges and it is removing the second filter leaving the first one in place.

Many Thanks,