We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Get Primary Key Value

Thread ID:

Created:

Updated:

Platform:

Replies:

132018 Aug 8,2017 04:05 PM UTC Aug 11,2017 05:14 AM UTC ASP.NET MVC 3
loading
Tags: Grid
Fillipe Barbosa
Asked On August 8, 2017 04:05 PM UTC

Good Afternoon,

I'm trying to get the value of primary key from row that i double click, but it doesn't show nothing.

                @(Html.EJ().Grid<object>("grid")
    .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource).InsertURL("/Home/PerformInsert").UpdateURL("/Home/PerformUpdate").RemoveURL("/Home/PerformDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
    .ToolbarSettings(tool => tool.ShowToolbar().ToolbarItems(item =>
    {
        item.AddTool(ToolBarItems.Add);
        item.AddTool(ToolBarItems.Cancel);
    }))
    .IsResponsive(true)
    .EnableResponsiveRow(true)
    .AllowFiltering()
    .FilterSettings(filter => { filter.FilterType(FilterType.Menu); })
    .AllowSorting(true)
    .AllowPaging()
    .AllowGrouping()
    .AllowResizing().AllowResizeToFit().AllowTextWrap()
    .Columns(col =>
    {
        col.Field("codigo_perfil").Visible(true).HeaderText("Código Perfil").IsIdentity(true).IsPrimaryKey(true).TextAlign(TextAlign.Right).Add();
        col.Field("descricao").HeaderText("Descrição").AllowEditing(false).Add();
        col.Field("ativo").HeaderText("Ativo").EditType(EditingType.Boolean).TextAlign(TextAlign.Center).Add();
        col.Field("codigo_tipo").HeaderText("Tipo").AllowEditing(false).Add();
        col.Field("codigo_acesso").HeaderText("Acesso").AllowEditing(false).Add();
    })
    .PageSettings(p => p.PageCount(3).PageSize(7))
    .ClientSideEvents(eve =>
    {
        eve.RecordDoubleClick("recordDoubleClick");
    })
                )

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

function recordDoubleClick(args) {
                        var grid = $("#grid").ejGrid("instance");
                        var index = grid.getIndexByRow(this.element.closest("tr"));
                        var record = grid.getCurrentViewData()[index];
                        var primaryKeyValue = record[codigo_perfil];

                        document.getElementById('labelId').textContent = primaryKeyValue;
                    }

Thanks for now.

Renjith Singh Rajendran [Syncfusion]
Replied On August 9, 2017 10:46 AM UTC

Hi Fillipe, 

Thanks for contacting syncfusion support, 

The value of the primary key will be passed as argument to the recordDoubleClick event handler when the record is double clicked. So you can get the value of the primary key from the args parameter passed to the function. 

Please refer the code below, 

<script type="text/javascript"> 
    function recordDoubleClick(args) { 
            var grid = $("#Grid").ejGrid("instance"); 
            document.getElementById('labelId').textContent = args.data[grid.getPrimaryKeyFieldNames()[0]]; 
        } 
</script> 

We have also prepared a sample which can be downloaded from the link below, 

Regards, 
Renjith Singh Rajendran. 


Fillipe Barbosa
Replied On August 10, 2017 05:51 PM UTC

Thanks, I did what you told me and worked.


Thavasianand Sankaranarayanan [Syncfusion]
Replied On August 11, 2017 05:14 AM UTC

Hi Fillipe, 

We are happy that the problem has been solved. 
 
Please get back to us if you need any further assistance.  
                          
Regards, 
Thavasianand S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;