Next Button that moves master record

QuestionsNext Button that moves master record
Glenn asked 9 years ago

Hi
Looking for a way to click a button and have the master record move to the next record.
By moving to the next record it would then update all the detail records automatically.

Thanks
Glenn

4 Answers
Abu Ghufran answered 9 years ago

You can refer this link, and bind on some button click event.

http://stackoverflow.com/a/7298901/385377

Replace:
var grid = $("#grid").jqGrid({…}); with your grid id,
e.g.
var grid = $("#list1");

Abdullah answered 9 years ago

Abu, could you create example? Thanks.

Glenn answered 9 years ago

Thanks Abu,

Unfortunately I could not get it working.
To test it I also updated your master-detail.php demo with the below code.
http://websalesdesign.com/proj/lib/phpgrid-full/index.php
The code below is the same as the stackoverflow except the list1 change.

<input type="button" value="Next" id="btnNext">

<script>
$('#btnNext').click(function () {

var grid = $("#list1").jqGrid({…});

var selectedRow = grid.getGridParam('selrow');
if (selectedRow == null) return;

var ids = grid.getDataIDs();
var index = grid.getInd(selectedRow);

if (ids.length < 2) return;
index++;
if (index > ids.length)
index = 1;
grid.setSelection(ids[index – 1], true);

});
</script>

Regards,
Glenn

Glenn answered 9 years ago

My bad.
I took another look right after I sent the email.
Changed the line like you said and it works like a charm.
var grid = $("#list1").jqGrid();

Thank You Abu!

Your Answer

9 + 4 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?