Setting AxGridView index in C# and in AX 2012
Sometimes we face issue with AxGridView to set the selected row as current. This may be due to number of reasons like if you are doing some task or operation in that process we are somehow running “executeQuery” of the data set.
Here is the small example to set the AxGridView index.
Step1: Add an AxGridview.
Step2: Add Data set and add fields
Step3: In the properties of AxGridView write an event “Selectedindexchanging”
onselectedindexchanging="SelectedRow_Changing"
Step4: write the below code in “SelectedRow_Changing” method.
protectedvoid SelectedRow_Changing(object sender, GridViewSelectEventArgse)
{
int i;
i = e.NewSelectedIndex; // get the new selected index
//Set new changed index as current row in data set.
DataSetViewdataSetView;
dataSetView = this.MkTempSelectedDS.GetDataSet().DataSetViews["TmpFrmVirtual"];
dataSetView.SetCurrent(i);
}
Now we will see how we can also set through AX
Step1: Goto Data set, Data source execute method which you want to modify.
In my example \Data Sets\MkSalesListEntry\Data Sources\SalesLine\Methods\executeQuery
Step2: write the below code in executeQuery method
public void executeQuery()
{
SalesLine lSalesLine;
lSalesLine = SalesLine.data();
super();
Salesline_ds.findRecord(lSalesLine);
Salesline_ds.setCurrent();
}
Happy Learning J



Tidak ada komentar:
Posting Komentar