Hi all,
I need to put a message when my Datagrid don't have any records, how I can do this?
I Have iggrid that is loaded with dataSourceUrl
I works with MVC 4
thanks for advance
Hello Ruben,
Thank you for your reply. Glad that you have found a solution! Please do not hesitate to contact me if you have any further questions regarding this matter.
Sorry, I Found the solution the solution alone xD
this code works perfectly:
<script type="text/javascript">
$("#igGrid1").live("iggridfilteringdatafiltered", function (sender, args) {
if ($("#igGrid1").igGrid("rows").length === 0) { if ($("#igGrid1_scroll").find(".iggrid-empty").length === 0) { $("#igGrid1_scroll").prepend("<div class='iggrid-empty'></div>"); //$("#igGrid1_scroll").find(".ui-iggrid-table, .ui-iggrid-footer").hide(); } var idioma = '@Session["idiomacmb"]'; switch (idioma) { case "0": //CAS $("#igGrid1_scroll").find(".iggrid-empty").append( $("<div class='sms_no_records_found'>Lo sentimos, no se ha localizado ningún resultado</div>")); break; case "1": //CAT $("#igGrid1_scroll").find(".iggrid-empty").append( $("<div class='sms_no_records_found'>Ho sentim, no s’ha trobat cap resultat</div>")); break; case "2": //ENG $("#igGrid1_scroll").find(".iggrid-empty").append( $("<div class='sms_no_records_found'>Sorry, no matching results found</div>")); break; case "3": //FRA $("#igGrid1_scroll").find(".iggrid-empty").append( $("<div class='sms_no_records_found'>Désolés, aucun résultat correspondant trouvé</div>")); break; case "4": //ITA $("#igGrid1_scroll").find(".iggrid-empty").append( $("<div class='sms_no_records_found'>Spiacenti, nessun risultato trovato</div>")); break; } } else { $("#igGrid1_scroll").find(".iggrid-empty").remove(); } });
</script>
One more question:
if after show this message i change filter, grid show records but show the message too.
How i can't delete this message and show records normally?
a lot of thanks for advance
Great Petar!!! finally i do this with a javascript function, a lot of thanks, I put here my code:
if ($("#table1").igGrid("rows").length === 0) { if ($("#igGrid1_scroll").find(".iggrid-empty").length === 0) { $("#igGrid1_scroll").prepend("<div class='iggrid-empty'></div>"); $("#igGrid1_scroll").find(".ui-iggrid-table, .ui-iggrid-footer").hide(); } var idioma = '@Session["idiomacmb"]'; switch (idioma) { case "0": //CAS $("#igGrid1_scroll").find(".iggrid-empty").append( $("<div class='sms_no_records_found'>Lo sentimos, no se ha localizado ningún resultado</div>")); break; case "1": //CAT $("#igGrid1_scroll").find(".iggrid-empty").append( $("<div class='sms_no_records_found'>Ho sentim, no s’ha trobat cap resultat</div>")); break; case "2": //ENG $("#igGrid1_scroll").find(".iggrid-empty").append( $("<div class='sms_no_records_found'>Sorry, no matching results found</div>")); break; case "3": //FRA $("#igGrid1_scroll").find(".iggrid-empty").append( $("<div class='sms_no_records_found'>Désolés, aucun résultat correspondant trouvé</div>")); break; case "4": //ITA $("#igGrid1_scroll").find(".iggrid-empty").append( $("<div class='sms_no_records_found'>Spiacenti, nessun risultato trovato</div>")); break; } }
});
PD: how i can put my code like you? it's more easy to undertand like your code
Thank you for your reply.
For achieving the same requirement when filtering, the selectors need to be modified (you are correct that the datafiltered event can be handled for the task):
dataFiltered: function (evt, ui) { if ($("#table1").igGrid("rows").length === 0) { if ($("#table1_scroll").find(".iggrid-empty").length === 0) { $("#table1_scroll").prepend("<div class='iggrid-empty'></div>"); //$("#table1_scroll").find(".ui-iggrid-table, .ui-iggrid-footer").hide(); } $("#table1_scroll").find(".iggrid-empty").append( $("<div class='ui-priority-primary'>( No items could be found )</div>")); } else { $(".iggrid-empty").css("display","none"); } }
Please note however that the filtering feature of igGrid also allows setting a filter summary via thefilterSummaryTemplateoption.
http://help.infragistics.com/jQuery/2013.2/ui.iggridfiltering
Attached is also my test sample for your reference.
Hope this helps.