开发者

Devexpress ASPxGridView GetSelectedFieldValues Can't get values

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

So when i change page index data is lost. After that i wrote bind code to grid's PageIndexChanged event. Now it works like charm.

But GetSelectedFieldValues works only at first page when SelectionChanged event occurs.

In example when i select a row at first page it gets the field values that i want. But when i change pageindex GetSelectedField cannot get the field values. It alerts empty text.

If i select a row at second page index it works at that page too, but when i change page index it's broken again.

BTW it works when i bind the grid at PageLoad event without !IsCallback condition but i can't bind it at Page_Load event bec开发者_JAVA百科ause of other controls must have to change the query and so data.

Here goes my javascript function which alerts selected values

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

And page index changed event

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.
    }
}


I think this is not the correct way to get the values from the grid at 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: is your grid support multiple selection?

Edit1: Check the following Examples as well:

How to use a GetSelectedFieldValues method to obtain values of several columns at once

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


ASPxClientGridView.GetSelectedFieldValues method send a callback to get the specified data. So, if you don't bind the ASPxGridView at the server side on this callback (and you actually don't - because of condition [ if (!IsCallback) ]) grid cannot return the data.

BTW, this works on the currect page because ASPxGridView is caching the data for the current page (see EnableRowsCache property definition).


You may want to try turning off callbacks for the grid. I've found that this solves some issues that I run into with the grid. I am not sure this will work, but it may be worth a shot.

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

Note...Although the grid should still work just fine, this may affect other code you may already have in place.


And also please check the KeyFieldName of Grid. If this information is not specified or not correct you may also not be able to retrieve the values in GetSelectedFieldValues client event.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜