jqGrid lose sort when paging - jqgrid-asp.net

I have a jqGrid. A few of my settings are:
url: '/Operations.aspx/GetData',
datatype: 'json',
mtype: 'POST',
loadonce: true,
multiSort: true,
sortname: 'PrimerApellido asc, SegundoApellido asc, Nombre',
sortorder: 'asc',
jsonReader: {
root: 'd.rows',
page: 'd.page',
total: 'd.total',
records: 'd.records',
id: 'Id',
repeatitems: false
},
My colModel includes the columns Nombre, PrimerApellido and SegundoApellido (in this order, and with the same name and index: column Nombre has name 'Nombre' and index 'Nombre'). I set rowTotal in loadComplete with
$this.jqGrid('setGridParam', { rowTotal: $this.jqGrid('getGridParam', 'records') });
The grid shows the data correctly, but when I change the page, the data appears sorted by Nombre, PrimerApellido, SegundoApellido, and I can't sort by my settings :(
Anyone can help me?

Related

how can I configure a simple eventlistener on symfony

``I tried to add an event listener on a field of a formular, but it doesn't work at all ; a var_dump on the variable gives allways the value "null", whatever I can do.
Is there something to do in the folder services.yaml, or some javascript to add somewhere ?
I'm total beginner, but I love this project and I would really like to succed in it.
->add('tournamentGame', ChoiceType::class, [
'choices' => [
'oui'=>true,
'non'=>false,
],
'data'=>true,
"attr"=>[
'class'=>'ms-2',
],
'multiple'=> false,
'label'=>'Mode Tournoi',
'mapped' => true,
'required' => false
])
;
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) {
$form = $event->getForm();
// this would be your entity, i.e. SportMeetup
$tournamentGame = $event->getData();
$multiplayer = $tournamentGame->isTournamentGame();
$nbTotalPlayer = null === $tournamentGame ? [] : $multiplayer;
$choice = false === $multiplayer ? ['2 joueurs'=>2,
'4 joueurs'=>4,
'6 joueurs'=>6,
'8 joueurs'=>8,
'10 joueurs'=>10,
'12 joueurs'=>12,
'14 joueurs'=>14,
'16 joueurs'=>16,
'18 joueurs'=>18,
'20 joueurs'=>20,] :
[];
$form->add('nbTotalPlayer', ChoiceType::class, [
'label' => 'Nombres de joueurs',
'choices'=>$choice,
]);
var_dump($multiplayer);
}
);
I've joined this jquery to the template, In the console I can see that the variable tournament has the correct values, but I need to return it into the the form in php, maybe it would be easier for you to understand what I want to do, I have to change the part with function(html), but I don' know what I can replace it with.
<script>
var tournamentGame = $('#game_tournamentGame');
// When sport gets selected ...
tournamentGame.change(function() {
// ... retrieve the corresponding form.
var $form = $(this).closest('form');
// Simulate form data, but only include the selected sport value.
var data = {};
data[tournamentGame] = parseInt(tournamentGame.val());
// Submit data via AJAX to the form's action path.
console.log(data[tournamentGame]);
$.ajax({
url : $form.attr('action'),
type: $form.attr('method'),
data : data,
complete: function(html) {
// Replace current position field ...
$('#game_nbTotalPlayer').replaceWith(
// ... with the returned one from the AJAX response.
$(html.responseText).find('#game_nbTotalPlayer')
);
// Position field now displays the appropriate positions.
}
});
});
</script>
dd($tournamentGame)

How to order ngrx entity collection

I have a response from backend like this:
[{ id: 4, name: 'Andrew'},
{id: 3, name: 'Rebecca'},
{id: 2, name: 'Joseph'},
{id: 1, name: 'Kristin'}]
The order is by descending id. From the last one to first one.
I have an entityAdapter defined in this way:
export const folderAdapter: EntityAdapter<Person> = createEntityAdapter<Person>({
selectId: person => person.id,
sortComparer: false,
});
into the reducer I created this function:
on(PeopleActions.loadAllPeople, (state, action): PeopleState => {
return {
...state,
people: adapter.addMany(action.people, state),
};
}),
when I go to see my state I have this situation:
ids:[4,3,2,1],
entities: {1: {id: 1, name: 'Kristin'}, 2: {id: 2, name: 'Joseph'}, 3: {id: 3, name: 'Rebecca'}, 4: { id: 4, name: 'Andrew'}}
}
This also happen into the ngFor. I tried to set return value to zero in ngfor keyvalue but nothing change. How can I change the order in entities? is there a particular property?
The EntityAdapter has the parameter sortComparer for this exact purpose.
All you need it to instead of using
sortComparer: false
you give it the function you would like to have sorting your entity ids
sortComparer: (a ,b) => a.id - b.id
As per ngrx's docs:
If provided, the state.ids array will be kept in sorted order based on comparisons of the entity objects, so that mapping over the IDs array to retrieve entities by ID should result in a sorted array of entities.
If not provided, the state.ids array will not be sorted, and no guarantees are made about the ordering. In other words, state.ids can be expected to behave like a standard Javascript array.

Entity Framework Core Cascade Delete Error

Though it has been set to on-delete: "ReferentialAction.Restrict" on foreign key "FK_TeamMember_Teams_TeamId", it gives the following error when trying to delete a record from TeamMember table. Can you please help me with how I should get rid of this error?
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries.
See the inner exception for details.
---> Microsoft.Data.SqlClient.SqlException (0x80131904): The DELETE statement conflicted with the
REFERENCE constraint "FK_TeamMember_Teams_TeamId". The conflict occurred in database "mot", table
"dbo.TeamMember", column 'TeamId'. The statement has been terminated.
Following is the migration code block
migrationBuilder.CreateTable(
name: "TeamMember",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
MarketingOfficerId = table.Column<Guid>(nullable: false),
TeamId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TeamMember", x => x.Id);
table.ForeignKey(
name: "FK_TeamMember_Employees_MarketingOfficerId",
column: x => x.MarketingOfficerId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TeamMember_Teams_TeamId",
column: x => x.TeamId,
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
OnModelCreating method I have used the following as well.
modelBuilder.Entity<Team>()
.HasMany(i => i.TeamMembers)
.WithOne(i=>i.Team)
.OnDelete(DeleteBehavior.Restrict);
Thank You
I think the behavior is correct since when the master table deletes a record it should delete its related records in the detail table. No point in keeping it. Data will be redundant. But in case if we want to make such a scenario, though we set CascadeDelete to Restrict within the migration.cs it will not work as expected. The following article will help with understanding the behaviours.
https://learn.microsoft.com/en-us/ef/core/saving/cascade-delete

Define Multiple-Columns as PK in YDN-DB

When define a schema with ydn-db I can define a single column as PK with this code:
var products = {
name: 'products',
keyPath: 'id_product',
autoIncrement: true,
indexes: [
{keyPath: 'id_product'},
{keyPath: 'id_supplier'}
]
};
var schema = {
stores: [products]
};
How I can define a Store (table) with one PK with two columns or more? Thanks
How I can define a Store (table) with one PK with two columns or more?
I am not sure answering your question. IndexedDB (ynd-db is very IDB centric) can have only one PK. But primary key can be compound key compose of multiple keyPath (column) using array keypath. It is define like this
var products = {
name: 'products',
keyPath: ['id_category', id_product']
};

send POST data from calendar to json_events.php

I imagine this is simple but I can't quite get the concept clear.
Basically I am working on loading events on prev/next click
viewDisplay: function(view) { var next = view.title; }, //alert(next);
gives me "November 2012"
split this
then
events: {
url: 'json-events.php',
type: 'POST', <br/>
data: { month: month,
year: year } },
So, how to read the POST val in json-events.php
Assuming I am on the right track here. [super newbie]
use as object reference http://arshaw.com/fullcalendar/docs/event_data/Event_Object/
<?php
//obtain params
$month = $_POST["month"];
$year = $_POST["year"];
//... get the list of events due to month and year
//create an events array due to docs
$events = array(array('id' => 1, 'title' => 'Event', 'allDay' => true));
//return json feed
echo json_encode($events);
?>

Resources