jquery - How to obtain the primary key of the selected row in bs_grid -


i'm using bs_grid display list of company names. each company name has guid identifier. define grid such:

$(function() {   $('#grid1').bs_grid({     ajaxfetchdataurl: 'companieslist.asmx/getcompanies',     row_primary_key: 'companyuid',     usefilters: false,     usepagination: false,     columns: [{       field: 'companyuid',       visible: 'no'     }, {       field: 'companyname',       header: 'company name'     }],     sorting: [{       sortingname: 'companyname',       field: 'companyname',       order: 'ascending'     }],     onrowclick: function(event, data) {       var selectedids = $('#grid1').bs_grid('selectedrows', 'get_ids');       // here need primary key of row, not row index:       location.href = 'companydetails.aspx?companyuid=' + selectedids[0];     }   }); }); 

i've poured on bs_grid js source , it's not jumping out @ me how obtain data row based on row_id. how should go getting information?

ok, bs_grid expects primary key int. results in guid not being read correctly , data.row_id being "random".

to solve this, had add row counter, starting @ 1, results use uid of hidden column companyuid.

$(function() {                 $('#grid1').bs_grid({                     ajaxfetchdataurl: 'companieslist.asmx/getcompanies',                     row_primary_key: 'rowid',                     usefilters: false,                     usepagination: false,                     columns: [                         { field: 'rowid', visible: 'no'},                         { field: 'companyuid', dataclass: 'td_code hidden', headerclass: 'td_code hidden'},                         { field: 'companyname', header: 'company name'}                     ],                     sorting: [                         { sortingname: 'companyname', field: 'companyname', order: 'ascending'}                     ],                     onrowclick: function(event, data) {                          if(data.row_status == 'selected')                         {                             var row =  $('[id^=tbl_grid1_tr_]:eq(' + data.row_id + ')');                             var uid = row[0].childnodes[0].innertext;                             location.href = 'companydetails.aspx?companyuid=' + uid;                          }                     }                 });             }); 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -