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,
Information on how a custom message may be displayed in the igGrid when there are no records can be found at:
http://es.infragistics.com/community/forums/p/68274/346033.aspx
Please do not hesitate to contact me if you have any questions.
Hi Petar
thanks for advance, this code i have to put in <script> code?
This is my grid code
<div style="width: 100%; float: left; height: 510px; padding-bottom: 20px;"> @( Html.Infragistics().Grid<DocumentosMetodos.DocumentsModels.DOCUMENTOSNOTGRID>() .ID("igGrid1") .PrimaryKey("uniCODOBJ") .Columns(column => { column.For(x => x.uniCODSER).DataType("string").HeaderText(@Resources.Resource1.DocumentosIndexGridSerie).Width("15%"); column.For(x => x.strTITOL).DataType("string").HeaderText(@Resources.Resource1.DocumentosIndexGridTitulo).Width("20%"); column.For(x => x.strFECINI).DataType("date").HeaderText(@Resources.Resource1.DocumentosIndexGridFecIni).Width("21%").Format("dd/MM/yyyy"); column.For(x => x.strFECFIN).DataType("date").HeaderText(@Resources.Resource1.DocumentosIndexGridFecFin).Width("21%").Format("dd/MM/yyyy"); column.For(x => x.strFIRTOP).DataType("string").HeaderText(@Resources.Resource1.DocumentosIndexGridFirma).Width("16%"); column.For(x => x.strCODREF).DataType("string").HeaderText(@Resources.Resource1.DocumentosIndexGridId).Width("12%"); }) .Features(features => { features.Paging().PageSize(15).PrevPageLabelText(@Resources.Resource1.DocumentosIndexGridAnterior).NextPageLabelText(@Resources.Resource1.DocumentosIndexGridSiguiente); features.Sorting().Mode(SortingMode.Single).ColumnSettings(settings => { settings.ColumnSetting().ColumnKey("strCODREF").AllowSorting(true);
}); features.Selection().MouseDragSelect(true).MultipleSelection(true).Mode(SelectionMode.Row); features.Filtering().ColumnSettings(settings => { //settings.ColumnSetting().ColumnKey("strFECINI").AllowFiltering(true).FilterCondition("equals"); });
})
.ClientDataSourceType(ClientDataSourceType.JSON) .DataSourceUrl(Url.Action("GetDocumentosNotarioList")) .Width("100%") .Height("100%") .LocalSchemaTransform(true) .DataBind() .Render() } )</div>
i do it!!!!
Thanks a lot for help!!
i do this
$("#igGrid1").live("iggridrendered", function (sender, args) {
if (args.owner.dataSource.dataView().length === 0) { if (args.owner.element.parent().find(".iggrid-empty").length === 0) { args.owner.element.parent().prepend("<div class='iggrid-empty'></div>"); args.owner.element.parent().find(".ui-iggrid-table, .ui-iggrid-footer").hide(); } args.owner.element.parent().find(".iggrid-empty").append( $("<div class='ui-priority-primary'>( No items could be found )</div>")); }
});
Thank you for your reply. Glad that the issue has been resolved !
Please do not hesitate to contact me if you have any further questions regarding this matter.
Hi petar,
I need the same but only when grid is filtered and don't have any records
I found this event: iggridfilteringdatafiltered, but i put the same code and don't works
please any suggest?, thanks for advance petar!
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.
Great Petar!!! finally i do this with a javascript function, a lot of thanks, I put here my code:
$("#igGrid1").live("iggridfilteringdatafiltered", function (sender, args) {
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. 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">
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