This is a migrated thread and some comments may be shown as answers.

[Solved] dataItem.getDataKeyValue seems to load wrong value

6 Answers 166 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Oleg Medyanik
Top achievements
Rank 1
Oleg Medyanik asked on 22 Sep 2009, 11:15 AM
Hi,
I am using client side binding and it seems to me that getDataKeyValue retrieves wrong values.
screenshot

On screen shot you see how i retrieve values from grid and actual variable values.
_dataItem contains correct values, but getDataKeyValue returns incorrect.

Am i doing something wrong?

Telerik.Web.UI.dll version is 2009.2.826.35
browsers - FF3.5.3 and IE 8

6 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 25 Sep 2009, 11:51 AM
Hello Oleg,

I am attaching a sample project I made for you showing how to extract datakey values client side.

Please take a look at it and tell me whether you find it useful.

Best wishes,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Oleg Medyanik
Top achievements
Rank 1
answered on 28 Sep 2009, 06:26 AM
Hi Mira.
Thank you, but seems you've attached project showing how to make grid selectable only by clicking check boxes.

I am currently using workaround like this
var dataItem = GetGridMtv().get_dataItems()[rowindex];
//var invalid = dataItem.getDataKeyValue("IsInvalid"); <-- returns wrong value
var invalid = dataItem._dataItem.IsInvalid; <--returns right value
0
Mira
Telerik team
answered on 30 Sep 2009, 01:27 PM
Hi Oleg,

I am attaching a modification of the project I sent you in which the rows are selected on row click and the getDataKeyValue() method returns the correct values.

Please take a look at it and tell me whether you find it useful.

Greetings,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Oleg Medyanik
Top achievements
Rank 1
answered on 30 Sep 2009, 06:37 PM
Hi Mira.
I've slightly modified attached project to show when getDataKeyValue is not working for me
JS:
        function RowSelected(sender, args) 
        { 
            var tmp = sender.get_masterTableView().get_selectedItems()[0].getDataKeyValue("Discontinued"); 
            var tmp2 = sender.get_masterTableView().get_selectedItems()[0]._dataItem.Discontinued; 
            alert("getDataKeyValue returned: " + tmp + "\nDirect access returned: " + tmp2); 
        } 

C#
 <MasterTableView ClientDataKeyNames="Name,Discontinued"

That's all in code modifications.

Now please filter
 Name - Starts with "Gula"
 Unit Price - Sort Desc
On 2nd or 3d click in grid i receive different values (i suspect it is true for bool type)
Here is the Screenshot showing vars in debugger and in alert window

Thank You!

0
Mira
Telerik team
answered on 06 Oct 2009, 09:16 AM
Hello Oleg,

Unfortunately I still unable to replicate the described issue. I added the Discontinued column in my project and tried following your steps and everything works as expected. You can see this video for further details.

If the problems continue, please open a formal support ticket and attach a sample project replicating them. We will debug it locally and get back to you with our findings.

Sincerely yours,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Oleg Medyanik
Top achievements
Rank 1
answered on 07 Oct 2009, 06:33 AM
Thanks Mira for your time and care.
I currently have workaround.

Even if you fix something there will be too much code to change on my side )).

Sincerely yours, Oleg

Tags
Grid
Asked by
Oleg Medyanik
Top achievements
Rank 1
Answers by
Mira
Telerik team
Oleg Medyanik
Top achievements
Rank 1
Share this question
or