Devexpress ASPxGridView GetSelectedFieldValues ​​Unable to get values

I am using gridview with paging. My grid has a command column, and ShowSelectCheckbox is true. I bind the DataTable to the grid in the Page_Load event with the condition [ if (!IsCallback) ].

Therefore, when I change the page index data, it is lost. After that, I wrote the binding code for the grid event of PageIndexChanged . Now it works like a charm.

But GetSelectedFieldValues only works on the first page when the SelectionChanged event occurs.

In the example, when I select a row on the first page, it gets the values ​​of the fields that I want. But when I change the pageindex GetSelectedField , it is not possible to get the field values. He warns the blank text.

If I select a row in the second index of the page, it also works on this page, but when I change the index of the page, it breaks again.

BTW works when I bind the grid to the PageLoad event without the condition !IsCallback , but I cannot bind it to the Page_Load event because other controls must change the request and therefore the data.

Here comes my javascript function that warns selected values

 <ClientSideEvents SelectionChanged="function(s, e) { grid.GetSelectedFieldValues('SDNO;SANTRAL',alert); }" /> 

And the event with the modified page index

 protected void myGrid_PageIndexChanged(object sender, EventArgs e) { myGridDataSource = dtable; //dtable is static, i also used BindThat function here too. But no way out. myGridDataBind(); } protected void Page_Load(object sender, EventArgs e) { if (!IsCallback) { BindThat(); // Fetch data from db, create dtable and bind it to grid. } } 
+4
source share
4 answers

I think this is not the right way to get values ​​from the grid on the client side, check the following link: http://www.devexpress.com/Support/Center/p/Q94237.aspx

 [JScript] function Button1_onclick() { ASPxGridView1.GetSelectedFieldValues("CategoryID;CategoryName", OnGetSelectedFieldValues); } function OnGetSelectedFieldValues(result) { for(var i = 0; i < result.length; i ++) for(var j = 0; j <result[i].length; j++) { alert(result[i][j]); } } 

Question: Does your grid support several options?

Edit1 : Also check the following examples:

How to use the GetSelectedFieldValues ​​method to get values ​​of several columns at once

How to get the values ​​of the selected record from the server

+1
source

The ASPxClientGridView.GetSelectedFieldValues ​​method sends a callback to retrieve the specified data. Thus, if you do not bind ASPxGridView from the server side to this callback (but not really - because of the condition [if (! IsCallback)]), the grid cannot return data.

By the way, this works on a currect page because ASPxGridView caches data for the current page (see the definition of the EnableRowsCache property).

+1
source

You can try disabling callbacks for the grid. I found that this solves some of the problems that I encounter with the grid. I'm not sure if this will work, but it may be worth it.

 <dxwgv:ASPxGridView ID="xgvMyGrid" runat="server" AutoGenerateColumns="False" EnableCallBacks="False"> 

Note. Although the grid should work fine, it may affect other code that you already have.

0
source

And also check out KeyFieldName for the Grid. If this information is not specified or is not specified correctly, you also cannot get values ​​in the GetSelectedFieldValues ​​client event.

0
source

Source: https://habr.com/ru/post/1310971/


All Articles