Telerik Forums
Kendo UI for jQuery Forum
4 answers
510 views
I am trying to add a confirmation dialog to an upload, can make it work using the standard confirm function but would like to use a custom dialog instead.

Markup below correctly displays the dialog but can't work out where to place e.preventDefault() to stop the upload or how to allow upload if user clicks OK.

$(document).ready(function () {
 
      $("#attachments").kendoUpload({
          async: {
              saveUrl: '@Url.Action("SaveAppointments", "Upload")',
              autoUpload: false,
          },
          upload: onUpload,
          select: onSelect,
          success: onSuccess
      });
  });
 
  function onUpload(e) {
            //Standard confirm works fine but would like to use a dialog
              //so style can be applied etc
               
      //if (!confirm("Is this upload for the correct candidate?")) {
      //    e.preventDefault();
      //    return;
      //}
 
       
      //Dialog shows correctly but how do I stop
      //the upload if the user clicks no
      var kendoWindow = $("<div />").kendoWindow({
          title: "Confirm",
          resizable: false,
          modal: true
      });
 
      kendoWindow.data("kendoWindow")
      .content($("#upload-confirmation").html())
      .center().open();
 
      kendoWindow
      .find(".upload-confirm,.upload-cancel")
          .click(function () {
              if ($(this).hasClass("upload-confirm")) {
                  alert("Upload file...");
              }
              
              kendoWindow.data("kendoWindow").close();
          })
          .end()
 
 
      var files = e.files;
      $.each(files, function () {
          var ext = ".bmp .doc .docx .xls .xlsx .pdf .txt .jpg .jpeg .gif .zip .mp3 .wav .wmv .png .zipx .rar";
          if (ext.indexOf(this.extension) < 0) {
              alert("Incorrect file type, accepted file types are: .bmp, .doc, .docx, .xls, .xlsx, .pdf, .txt, .jpg, .jpeg, .gif, .zip, .zipx, .rar, .mp3, .wav, .wmv and .png")
              e.preventDefault();
          };
 
          if (this.size > 10485760) {
              alert("File too large, maximun upload size is 10mb")
              e.preventDefault();
          };
 
          if ($("#fileDescription").val() + '' == 'undefined') {
              alert("A file description is required.")
              e.preventDefault();
          };
 
          e.data = { fileDescription: $("#fileDescription").val(), appointmentid: $("#appointmentid").val() };
      });
 
       
  }

T. Tsonev
Telerik team
 answered on 20 Jun 2014
1 answer
837 views
HI Sir,

Good day.

Just would like to ask on how and where event to add confirm dialog before clicking the upload button  and how to add upload complete message or 100% complete once the upload is completed in kendo upload.

Here's my code below:


$(document).ready(function () {

        var lookup = $("#ComboLookupTable").data("kendoComboBox");
        $("#files").kendoUpload({
            async: {
                saveUrl: "Lookup/UploadFile",
                autoUpload: false,
                value: 'Import'
            },
            localization: {
                select: "Select a file",
                uploadSelectedFiles: "Import",
                headerStatusUploaded: "File validation",
                headerStatusUploading: "File uploading...",
                statusFailed: "Uploading file failed",
                statusUploaded: "File validating...",
                statusUploading: "Uploading..."
            },
            multiple: false,
            select: function (e) {
                confirmUpload();
               
            },
            upload: function (e) {
                lookup.enable(false);
                this.element.prop("disabled", true);
                this.element.closest(".k-button").addClass("k-state-disabled");
                 e.data = { selectedTable: $("#ComboLookupTable").val() };
            },
            success: function (e) {
                //debugger;
                resetUpload();
                if (e.XMLHttpRequest.responseText != '' && e.response != 'gridESREF' && e.response != 'gridFuelEfficiency' && e.response != 'gridConversionFactor' &&
                    e.response != 'gridGlobalEmissionFactor' && e.response != 'gridElectricalRegionalEmissionnFactor' && e.response != 'gridGWP') {
                    showErrorMsgsJson(e.XMLHttpRequest.responseText, 'windowDialog');
                    e.preventDefault();
                    dialog.close();
                }
                else {
                    var delay = 1500;
                    setTimeout(function () {
                        //grid names;
                        //gridRefresh(e.response);
                        dialog.close();
                    }, delay);
                }
            },
            complete: function (e) {
                resetUpload();
                this.element.prop("disabled", false);
                this.element.closest(".k-button").removeClass("k-state-disabled");
                lookup.enable(true);
            },
            error: function (e) {
                resetUpload();
                if (e.XMLHttpRequest.responseText != '') {
                    showErrorMsgsJson(e.XMLHttpRequest.responseText, 'windowDialog');
                    e.preventDefault();
                    dialog.close();
                }
            }

        });
    });

    function ConfirmCancel() {
        var kendoWindow = $("<div />").kendoWindow({
            title: "Upload",
            height: 130,
            width: 280,
            resizable: false,
            modal: true,
            animation: {
                open: {
                    effects: "fade:in",
                    duration: 500
                },
                close: {
                    effects: "slide:right fadeOut",
                    duration: 500
                }
            },
            visible: false
        });

        kendoWindow.data("kendoWindow")
            .content($("#cancel-upload").html())
            .center().open();

        kendoWindow
            .find(".delete-confirm,.delete-cancel")
                .click(function () {
                    if ($(this).hasClass("delete-cancel")) {
                        //If no
                        kendoWindow.data("kendoWindow").close();
                    }
                    else {
                        //If yes
                        resetUpload();
                        kendoWindow.data("kendoWindow").close();
                        dialog.close();
                    }
                })
    }

On my work, the confirm dialog is attached to Select event which is not a proper way.
Thank you in advance.
T. Tsonev
Telerik team
 answered on 20 Jun 2014
3 answers
340 views
Hi,

Is there a way to have different arrow colors for popover on the same page? I have the folowing code, which opens a red and a green popover:

http://jsbin.com/xopanitu/1/edit

As you see the red one (#popover1) is ok, but the green one (#popover2) is not, because it has a red arrow.

I can set the color of the arrow with the .km-popup-arrow:after css selector, but it is applied for all the popover arrows. How can I set to only apply it for #popover1 or only to #popover2? As I see the the structure of the popover is something like this:

<div data-role="popup">
           <div class="km-popup-arrow"></div>
           <div data-role="popover" id="popover1"></div>
</div>

The problem is that I can't get .km-popover-arrow div from #popover1 div with css selectors (there is no parent selector, and sibling selectors are also not working because the arrow preceeds the popover). 

As I see the only solution is to add an ID or class to the div with data-role="popup", but how? From the docs (http://docs.telerik.com/kendo-ui/api/mobile/popover#configuration-popup) there are only height, width, direction parameters for popop. Is there a way to add class or generate id for the popup div?

Thank you!
Kiril Nikolov
Telerik team
 answered on 20 Jun 2014
1 answer
101 views
Hello,
On login page as shown below, if there are any errors from the service call, I return to the same page and display errors. 
It works as expected, but the header part is gone missing when the login page is re-displayed with errors.
Using app.navigate to change the display based on success/failure scenarios.

Thanks for  your time and help.

--
Hiren





<!DOCTYPE html>

<html>
<head>
<title>My App</title>
<link href="../resources/css/kendo.mobile.all.min.css" rel="stylesheet" />
<script src="../resources/js/jquery.min.js"></script>
<script src="../resources/js/kendo.all.min.js"></script>
</head>

<body>
<div id="home" data-role="view" data-layout="default">
<h4>Sign in</h4>
<p>Username or email</p>
<p><input id="username" type="text" /></p>
<p>Password</p>
<p><input id="password" type="password" /></p>
<p/>
  <a href="kendoUI.html">Forgot your username or password</a>  
  <p/>  
<a data-role="button" data-click="login">Login</a>
 
<div id="errors"></div>
</div>
<section data-role="layout" data-id="default">
<header data-role="header">
<div data-role="navbar">My App</div>
</header>
<footer data-role="footer">
<div data-role="tabstrip">
<a href="#home">Continue As Guest</a>
</div>
</footer>
</section>


<script>
var app = new kendo.mobile.Application(document.body, 
   {
       transition:'slide'
   });

 
function login(){
var username = $("#username").val();
var password = $("#password").val();
  
var dataSource = new kendo.data.DataSource({
 transport: {
 read: {
          
           url: "http://localhost:8080/MyApp/rest/SecurityService",

           type: "POST",
           
           dataType: "json",

           data: { username: username, password : password }
}
 },
 requestEnd: function(e) {
 console.log("requestEnd");
// console.log(e);
   var response = e.response;
   console.log(response);
   
  var type = e.type;
  if (type === "read"){
  console.log("USERID : "+response.userId);
  app.navigate("homepanel.html");
  }else {
  console.log("error");
  $("#errors").html("User Not Found");
    app.navigate("#home");
  }
 
 }
});
dataSource.read();
 
}
 
    </script>
</body>
</html>
Petyo
Telerik team
 answered on 20 Jun 2014
1 answer
66 views
I just want to say thank you for reworking the Kendo UI documentation site. I really appreciate it - especially the performance boost.

Thanks
Holger
Kiril Nikolov
Telerik team
 answered on 20 Jun 2014
1 answer
177 views
I need show this format: 12.123,33 € for use it in Spain.
Change period (dot) for thousands and comma for decimals.

In my code I have:
<script type="text/javascript" src="js/kendo.culture.es-ES.js"></script>

The value of the decimal column (MySQL database) is: 12123.33
I tried with this code:
a)
$("#importe_oferta").kendoNumericTextBox({
culture: "es-ES"
format: "c2",
min: 0,
decimals: 2,
spinners: false
});
Result: 1.212.33.00 € ->wrong

b)
$("#importe_oferta").kendoNumericTextBox({
format: "c2",
min: 0,
decimals: 2,
spinners: false
)};
Result: $12,123.33 ->wrong

c)
$("#importe_oferta").kendoNumericTextBox({
min: 0,
decimals: 2,
spinners: false
 });
Result: 1,2123.43 ->wrong

And the same problem on the grid : 12,123.43 <-wrong

If anybody have the solution of this problem, please write a possible solution.
Thanks
Julio
Holger
Top achievements
Rank 1
 answered on 20 Jun 2014
1 answer
500 views
Hi.
I want to have the slider selection (just the visual marker) to start from the right side/ the max value, instead of the left.
I tried the RTL mode + swap the min/max values but this does not solve the problem.
Is it possible to do that?
Thanks.
Hristo Germanov
Telerik team
 answered on 20 Jun 2014
1 answer
191 views
I'm having problems with a template rendering when it includes the # character in it. All other special characters seem to work without a problem.except for the numerical sign.

http://jsbin.com/enutew/61/edit

This fails to render:
    <script id="tmp" type="text/x-kendo-template">
          <div>
               <label>#Value:</label>
                <label data-bind="text:attribute"></label>
           </div>
    </script>

While this renders fine:

    <script id="tmp" type="text/x-kendo-template">
          <div>
               <label>Value:</label>
                <label data-bind="text:attribute"></label>
           </div>
    </script>


Thanks!






Alexander Valchev
Telerik team
 answered on 20 Jun 2014
3 answers
285 views
Hello,

I have a grid with 3 columns. In the grid options, I indicated that columnMenu is true. I also specified a columnMenuInit, in order to customize the column menu. What I want to do is to add an input bound to the header of the column, allowing me to change it there.

I tried something like this:

function columnMenuInit(e) {
            var menu = e.container.find(".k-menu").data("kendoMenu");
            var field = e.field;
            menu.append({ text: "Input name: <input data-bind='value: "+ field +"'>", encoded: false });
}

but it does not seem to bind to anything (the input is empty when I show the column menu).

Would you have any advice?

Thanks in advance,
Marc.
Petur Subev
Telerik team
 answered on 20 Jun 2014
2 answers
376 views
Hi Team,
I have a Kendo Grid with enum column defined (column has a 'values' property set). In filter popup, I want to implement my own MultiSelectCombo control to be able to filter the column with multiple values. How can I do that? For non-enum columns I can implement a 'ui' method on 'column.filterable' object, but it seems that the method is not invoked for enum columns.
Pawel
Top achievements
Rank 1
 answered on 20 Jun 2014
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Drag and Drop
Application
Map
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
DropDownTree
ListBox
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
Licensing
PivotGridV2
ScrollView
Switch
TextArea
BulletChart
QRCode
ResponsivePanel
Wizard
CheckBoxGroup
Localization
Barcode
Breadcrumb
Collapsible
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
TimePicker
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?