75 articles Javascript Page 7 / 8

Kendo Grid Column Null Value

Kendo Grid menampilkan tulisan “null” jika data dari server null. Supaya Grid menampilkan cell kosong, gunakan fungsi javascript seperti berikut [code language=”javascript”] function isnull(a, b) { b = b || ”; return a || b; } [/code] Penggunaan di Grid [code language=”javascript”] { field: "whys", title: "Isu Kunci", template: "#= isnull(KeyIssue, ”) #", }, [/code]

Reloading / Refreshing Kendo Grid After AJAX

[code language=”javascript”] $(‘#GridName’).data(‘kendoGrid’).dataSource.read(); $(‘#GridName’).data(‘kendoGrid’).refresh(); [/code] read will request the server and reload only reload datasource. There will be no changes in the UI. refresh will re-render items in grid from the current datasource. That’s why both are required http://stackoverflow.com/questions/18399805/reloading-refreshing-kendo-grid Alternatif kalau ingin mengubah filter ketika me-reload grid: [code language=”javascript”] dataSource.query({ page: 1, pageSize: 10, filter:…

CKEditor Change Toolbar

[code language=”javascript”] CKEDITOR.config.toolbar = [ [‘Styles’,’Format’,’Font’,’FontSize’], ‘/’, [‘Bold’,’Italic’,’Underline’,’StrikeThrough’,’-‘,’Undo’,’Redo’,’-‘,’Cut’,’Copy’,’Paste’,’Find’,’Replace’,’-‘,’Outdent’,’Indent’,’-‘,’Print’], ‘/’, [‘NumberedList’,’BulletedList’,’-‘,’JustifyLeft’,’JustifyCenter’,’JustifyRight’,’JustifyBlock’], [‘Image’,’Table’,’-‘,’Link’,’Flash’,’Smiley’,’TextColor’,’BGColor’,’Source’] ] ; [/code] http://stackoverflow.com/questions/13499025/how-to-show-ckeditor-with-basic-toolbar

ASP Upload File AJAX using Kendo

File Upload menggunakan setting di Web.config dan MyGlobalMessage.resx. HTML code: [code language=”html”] <input name="files" id="kendo-upload" type="file" /> @Html.HiddenFor(model => model.FilePath) <img id="uploaded-image" src="@(Model.Photo != null ? Url.Content(Model.Photo) : "")" class="img-responsive" alt="" /> [/code] Tambahan di view cshtml [code language=”csharp”] @{ //… string fileTypeErrMsg = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "FileUploadImageTypeError").ToString(); string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "FileUploadSizeError").ToString(); string fileSizeErrMsg = string.Format(template,…

jQuery Notification When User Want to Leave Changed Form

Fungsi ini berguna untuk memberikan notifikasi kepada user, ketika user sudah mengubah form namun belum menyimpan perubahan tersebut. Penanganannya seperti di wordpress. [code language=”javascript”] var formChange = false; $("form").each(function () { $(this).find("input, select, textarea").change(function () { formChange = true; }); }); $(window).on("beforeunload", function () { if (formChange) { return "Perubahan data belum tersimpan."; } });…