New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
records status is not update to modified. Issue refrance #1552 #1555
Comments
Hi, |
Issue detail - if you are update any record manually then record add "w2ui-changed" this class for showing updated records and showing Red mark . But in my select all code this class not added this is a problem. and I am try to getting change record this is not working - This is a Red Mark - not showing if I am check my all records any other way to update record status by code and by forced My select all code is provided by #1552 @mpf82
|
Hy jackryu, https://fractalcosmo.com/MvcWebLog/paginaDefault.php You can do a multiselect untill 5 records(this is wanted by me) and when you click "variazione residenza" you can see in console browser that the array final is corrected.There is only a bug in w2ui 1.5.1 using both onSelect that onClick, because there are not working together with multiselect, it's an issue that i opened days ago. |
Issue
Code 0.1 :
this code suggest in - #1552 this issue by @mpf82 Code 0.2 :
|
Here's a little of confusion, you asked the reason because the red triangle of w2ui-changed class is not showing in your include column; $('#tb_'+nameGrid+'_toolbar_item_w2ui-save').removeClass('disabled'); But an arrow at your side it's that really this seems a bug because also in the w2ui demo the save button is not able....Like as in this example: http://w2ui.com/web/demos/#!grid/grid-17 You can force the removeClass disabled but also if you force the removeClass disable seems that there is not attached the event so you can't click the save button; Ciao Ps:So another way to do what you want it's create a custom save button in the toolbar, able and disabled with your own, on the onClick of the save custom button you do a loop of each records and get the parameters that you need to send at the server put all in array and send this array at the server.Simple, a more comfortable way it's give a class in the html render function of the include column in this way to check all and do the loop it's more comfortable, or you do a loop $(records).each(funtion(){}), yes you must detect if there was a check all or a simple multiselect of that checkbox....This is the work. |
|
I done a little variation at the grid that you see on my site: https://fractalcosmo.com/MvcWebLog/esempiW2ui.php?versione151OnlyOnSelect I attach you the code of the all javascript of all the grid, but using two checkbox column means do more work, do you know, because you must control everything. Create a button, in this case i named Get Selection Check, a quickly idea it's do two loops, one to get all the records and one to get the recid of checked, you can see i named the column CHECK, in the function <div id="risultatiVerione151">
<div class="spacer10"> </div>
<div class="containerBorderBlank" id="panelRisultatiVersione151">
<div id="gridVersione151" style="width:100%;height:100%"> </div>
</div>
</div><br> $(document).ready(function(){
timestamp = new Date().getTime();
//Sempre la destroy altrimenti va in errore di name già definito se viene chiusa e riaperta
$().w2destroy('gridVersione151');
//E lo show del div della griglia
$('#gridVersione151').show();
//un css di default
$('#gridVersione151').css({ width: '100%' }).animate({ height: '100%' }, 100);
$('#gridVersione151').w2grid({
name: 'gridVersione151',
header : '<div class=""><b>Esempio Dati w2ui Versione 1.5.rc1</b></div>',
multiSelect : true,
fixedBody : false,
msgNotJSON: '<div style="text-align:center"><b>Non ci sono validi risultati</b></div>',
show: {
header : true,
toolbar : true,
footer : false,
lineNumbers : false,
selectColumn : true,
expandColumn : false,
toolbarColumns : false,
toolbarSearch : true,
toolbarReload : false,
},
toolbar : {items:[
{ type: 'button', id: 'itemVariazione', caption: 'Variazione Residenza', icon: 'glyphicon glyphicon-edit', hint: 'Variazione Residenza' },
{ type: 'button', id: 'itemGetRecordSelected', caption: 'Get Selection Check', icon: 'glyphicon glyphicon-edit', hint: 'Get Selection on Check column' },
],
onClick: function (event) {
if (event.target == 'itemVariazione'){
variazioneDatoResidenza(arrayValori);
}
if (event.target == 'itemGetRecordSelected'){
getSelectedCheck();
}
},
},
columns: [
{ field: 'nome', caption: '<div style="text-align: center;">Nome<div>', sortable:true,size:'10%',attr: 'align=center' },
{ field: 'cognome', caption: '<div style="text-align: center;">Cognome<div>',sortable:true,size:'10%',attr: 'align=center'},
{ field: 'dataNascita', caption: '<div style="text-align: center;">Data Nascita<div>',size:'8%',sortable:true,attr: 'align=center'},
{ field: 'cittaResidenza', caption: '<div style="text-align: center;">Città Residenza*Double click to edit*<div>', sortable:true,size:'20%',editable: { type: 'text',style: 'background-color: #ffcccc' } },
{ field: 'input', caption: '<div style="text-align: center;">Check<div>', sortable:false,size:'20%',render:function(record){
return "<div style='text-align:center'><input type='checkbox' name='checkGrid' class='checkGrid' value='"+record.recid+"'></div>";
} },
],
searches: [
{ type: 'text', field: 'nome', caption: 'Nome',operator:'contains' },
{ type: 'text', field: 'cognome', caption: 'Cognome',operator:'contains' },
{ type: 'text', field: 'dataNascita', caption: 'Data Nascita',operator:'contains' },
{ type: 'text', field: 'cittaResidenza', caption: 'Città Residenza',operator:'contains' },
],
onChange: function(event){
event.onComplete = function(event) {
$(window).click(function(event){
$('.w2ui-changed').each(function(event){
$('.w2ui-changed').css('color','red');
});
});
};
},
onRefresh:function(event){
event.onComplete=function(event){
$('#grid_gridVersione151_check_all').hide();
//Inseriamo un title sulla input ricerca
$('#grid_gridElencoToDo_search_all').attr('title','Tutte le colonne sono ordinabili e ridimensionabili');
records = this.records;
colonne = this.columns;
totaleRisultati = this.totaleRisultati;
console.log(totaleRisultati);
//Inseriamo l'icona di sort al refresh ready della tabella per dare un feedback all'operatore
$(colonne).each(function(event){
$("td:contains('Nome')").find($('.w2ui-col-header > div')).eq(0).addClass('w2ui-sort-up');
$("td:contains('Cognome')").find($('.w2ui-col-header > div')).eq(0).addClass('w2ui-sort-up');
$("td:contains('Data')").find($('.w2ui-col-header > div')).eq(0).addClass('w2ui-sort-up');
$("td:contains('Residenza')").find($('.w2ui-col-header > div')).eq(0).addClass('w2ui-sort-up');
});
};
},
onLoad:function(event){
var response = [];
var responseText = (event.xhr.responseText);
//console.log(responseText);
response = responseText.match(/{.*(.*)\}/);
if (response != null){
var finale = response[0];
var arrayFinale = JSON.parse(finale);
var nazione = arrayFinale.nazione;
var nazionalita = arrayFinale.nazionalita;
var totaleRisultati = arrayFinale.totaleRisultati;
console.log(totaleRisultati);
console.log(nazione);
console.log(nazionalita);
var records = arrayFinale.records;
$(records).each(function(event){
});
}
},
onEditField:function(event){
//console.log(event);
//console.log(this);
event.onComplete=function(event){
//console.log(this);
//console.log(event);
id = event.recid;
$('#grid_gridVersione151_edit_'+id+'_3').keypress(function(event){
return noNumeri(event);
});
$('#grid_gridVersione151_edit_'+id+'_3').blur(function(event){
stringa = this.value;
repStringa = (stringa.replace(/[^a-zA-Z ]/g, ""));
$('#grid_gridVersione151_edit_'+id+'_3').val(repStringa);
});
};
$('.w2ui-changed').each(function(event){
$(this).css('color','red');
});
},
onSelect : function (event){
target = event.target;
//Oltre i 5 record selezionati blocchiamo con un unselect la possibilità di selezionare altri record
$.fn.bloccaSelezione = function(event){
var record = event.recid;
w2ui['gridVersione151'].unselect(record);
};
event.onComplete = function(event) {
//La getSelection ritorna le checkbox selezionate
sel = this.getSelection();
//console.log('this get selection ' +sel);
arrayValori = [];
if (sel.length == 0){
w2ui['gridVersione151'].toolbar.disable('itemVariazione');
}
else{
w2ui['gridVersione151'].toolbar.enable('itemVariazione');
}
if (sel.length > 5){
$(this).bloccaSelezione(event);
return;
}
target = w2ui[target];
//Al select delle checkbox inseriamo in un array chiave valore tutti i record
for (i=0; i < sel.length;i++){
//console.log(w2ui[target]);
recidRecord = sel[i];
//console.log('recid record :'+recidRecord);
records = target.records;
//console.log(records);
$(records).each(function(){
recidTarget = this.recid;
if (recidTarget == recidRecord){
//console.log(this);
recid = $.trim(this.recid);
id = $.trim(this.id);
nome= $.trim(this.nome);
cognome = $.trim(this.cognome);
dataNascita = $.trim(this.dataNascita);
cittaResidenza = $.trim(this.cittaResidenza);
arrayValori.push({recid:recid,id:id,nome:nome,cognome:cognome,dataNascita:dataNascita,cittaResidenza:cittaResidenza});
}
});
}
};
},
onUnselect : function(event){
target=event.target;
event.onComplete = function(event) {
sel = this.getSelection();
arrayValori = [];
if (sel.length == 0){
w2ui['gridVersione151'].toolbar.disable('itemVariazione');
}
else{
w2ui['gridVersione151'].toolbar.enable('itemVariazione');
}
target = w2ui[target];
//Sull'Unselect dobbiamo aggiornare l'array
for (i=0; i < sel.length;i++){
//console.log(w2ui[target]);
recidRecord = sel[i];
//console.log('recid record :'+recidRecord);
records = target.records;
//console.log(records);
$(records).each(function(){
recidTarget = this.recid;
if (recidTarget == recidRecord){
//console.log(this);
recid = $.trim(this.recid);
id = $.trim(this.id);
nome= $.trim(this.nome);
cognome = $.trim(this.cognome);
dataNascita = $.trim(this.dataNascita);
cittaResidenza = $.trim(this.cittaResidenza);
arrayValori.push({recid:recid,id:id,nome:nome,cognome:cognome,dataNascita:dataNascita,cittaResidenza:cittaResidenza});
}
});
}
};
},
onClick:function(event){
//event.preventDefault();
/*event.onComplete = function(event) {
id = event.recid;
//console.log(id);
$('#grid_gridVersione151_rec_'+id).find('td').eq(4).click();
};*/
},
onError:function(event){
event.preventDefault();
numeroErrore = event.message.errore;
if (numeroErrore == '99'){
div = $('<div class="info">').html('Nessun dato Presente<br><br>');
$('#panelRisultatiVersione151').append(div);
}
},
});
params = $.param({
timestamp : timestamp,
});
w2ui['gridVersione151'].load('esempiW2ui.php?versione=griglia151&'+params);
w2ui['gridVersione151'].resize();
w2ui['gridVersione151'].toolbar.disable('itemVariazione');
});
function getSelectedCheck(){
records = w2ui['gridVersione151'].records;
//console.log(records);
check = $('.checkGrid:checkbox:checked');
$(check).each(function(){
value = this.attributes.value;
console.log(value);
});
$(records).each(function(){
console.log(this);
});
}
function variazioneDatoResidenza(arrayValori){
residenzaCambiata = w2ui['gridVersione151'].getChanges();
//Abbiamo recuperato i campi ma dobbiamo controllare se sono state editate le residenze, se il recid è stato
//editato prendiamo le nuove residenze editate, lo facciamo qui quando l'operatore clicca la variazione che poi manda al server
$(arrayValori).each(function(i,j){
idArray = arrayValori[i].recid;
console.log(idArray);
$(residenzaCambiata).each(function(k,w){
recidEditato = residenzaCambiata[k].recid;
//console.log(recidEditato);
residenzaEditataAggiornata = residenzaCambiata[k].cittaResidenza;
if (recidEditato == idArray){
arrayValori[i].cittaResidenza = residenzaEditataAggiornata;
}
});
});
console.log(arrayValori);
} The Json result when the grid call/load the php can be seen here https://fractalcosmo.com/MvcWebLog/esempiW2ui.php?versione=griglia151 Ciao PS:I NOTIFIED THAT THERE IS AN ERROR IN ARRAYVALORE ONSELECT AND ONUNSELECT SORTING THE COLUMN AND AFTER SELECT SOME RECORDS WITH THE NORMAL MULTISELECT, THE RECID IF THE COLUMN IS SORTED ISN'T RIGHT...I must see this also on my project.Grrr i saw it now... PPS:I fixed the problem, the onSelect and onUnselect array worked well if column wasn't sorted, because the target was in order but after the sort the loop wasn't correct, instead now it's working well, i have updated the code over.....Bye |
Thanks for support @spizzi77 - This is complex code but ok I will try to make code as per your suggestion if you have any simple solution please suggest. |
Hy Jackryu,
If you must only check if the checkbox in the column is checked when the user do the onSelect event, you can do it with a simple _id_numberColumn is(':checked'), it depends from what you must do with that include column checkbox... |
Thanks @spizzi77 i will try... |
My issue is not resolve. |
in records array, all fields are kept in the direct object grid.records = [{ field1: 1, field2: 2}, {...}...] However, after you changed a field, 2 copies will be stored: old one and new one. The new one in rec.w2ui.changes. So, I am guessing if you modify that, and refresh grid, then it will show the triangle. Just a guess. See if this helps. |
Hello - I tried your suggestion @mrg2001
In "grid" variable updated records is not shown but on UI my all check box is unchecked. but red mark is not shown in front of updated record. Current Problem : red mark not shown & Updated Records in not display in changesobject. Your suggestion is good and you are very close to fix my problem thanks for your good!! suggestion. Please help and suggest how to show red mark and update UI checkbox |
No this is not working ....... as per your suggestion i am trying below code but this is not working on UI checkbox is unchecked but red mark is not shown. every thing is resolved excluding red mark
Sorry : above code posted by mistake correct code is correct cod is
Sorry for asking again and again but i am stack and this issue is critical fro me thank you very much for my support. But my issue still not resolved. please help me if possibly. |
Please create a jsFiddle and I will fix it there. |
jsfiddle attached @mrg2001 & @spizzi77 https://jsfiddle.net/JackRry/z5nvLf6j/8/ this is a jsfiddle link but W2ui not working on jsfiddle but my code is attached.
Requirment : if I am click on "btnInclude" this button then i need to "Between_Call_Marker" torggal this column check box and data show in "getChange" object and Red mark is show if record is update. |
Please Help......... ? |
Here you go http://jsfiddle.net/z5nvLf6j/10/ |
Thank!! You @mrg2001 appreciated!!!! your help. |
thanks - @mpf82 for resolved this issue : Set object is not update all records #1552
But this is not resolved completely description below
** records status is not update to modified.**
This code is not fill data in changes object so my changes object is display empty.
this red mark
but this is showing blank....
all record selected but red mark identifier is not showing on records
The text was updated successfully, but these errors were encountered: